Is there a way to override the selected row being reset after its datasource is refreshed? I currently have the datasource to the grid set to refresh every 10 seconds, and I notice with this code when I start clicking through the messageboxes eventually they will be empty because the selected row has changed back to the top. I'm using the messagebox to test getting values from the row.
Private Sub dgvUD01_ClickCellButton(ByVal sender As Object, ByVal e As CellEventArgs) 'Dim rootRow As UltraGridGroupByRow = dgvCNCReview.Rows(0) If e.Cell.Column.Key = "make" Then For i As Integer = 0 To dgvCNCReview.DisplayLayout.Bands(0).Columns.Count - 1 If dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Column.IsVisibleInLayout And (dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Column.Key <> "make" And _ dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Column.Key <> "buy") Then EpiMessageBox.Show(dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Text.ToString) End If Next ElseIf e.Cell.Column.Key = "buy" Then For i As Integer = 0 To dgvCNCReview.DisplayLayout.Bands(0).Columns.Count - 1 'Dim _cell As UltraGridCell = dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i) If dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Column.IsVisibleInLayout And (dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Column.Key <> "make" And _ dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Column.Key <> "buy") Then 'EpiMessageBox.Show(dgvUD01.DisplayLayout.Bands(aCell.Band.Index).Columns(i).ToString) EpiMessageBox.Show(dgvCNCReview.DisplayLayout.Rows(e.Cell.Row.Index).Cells(i).Text.ToString) End If Next End If End Sub
Thanks for any help,
Ted
Hi,
No. When you re-set the grid's DataSource or the grid gets a Reset notification form the data source, it has no choice by to throw away all of the rows and columns and the entire DisplayLayout and create a new one based on the new data source.
The best thing to do is avoid setting the DataSource and avoid doing things that will cause Reset notifications.
Is there a before and after event related to the grid refreshing? Then I could capture the current active row on the before event and then set the active row back to that row in an after event?
Thanks,