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,
[/quote]
tkoch77 said: When debugging the application, it appears as if InitializeLayout is never triggered when using the refresh button Epicor has provided.
When debugging the application, it appears as if InitializeLayout is never triggered when using the refresh button Epicor has provided.
That's odd. I'm not sure what their refresh button is doing, then. Maybe they are not sending a Reset notification, but instead they are simply changing the current position of the BindingManager and the grid is synchronizing.
They don't fire any event when the user clicks this button?
tkoch77 said: InitializeRow is triggered, perhaps I could do something there with the value?
InitializeRow is triggered, perhaps I could do something there with the value?
The problem with using InitializeRow is that it fires for every row. So I don't see how that would work efficiently. If you can detect when the user clicks the button, you could use a flag and only do something the first time InitializeRow fires after that. But if there is a way to detect a click on the button, then you don't need a grid event, anyway.
Mike,
Thanks for the input. I'll play around with this today and see where I get.
I've never used them, but I've heard the name before.
Unfortunately, the grid is responding to events of the DataSource in this case. The grid is a consumer of the events, in other words. So the grid doesn't fire any events.
Perhaps there are events fired by the Epicor objects that you could use to handle this?
The grid will fire InitializeLayout after it's DataSource is set. So perhaps you could track the ActiveRow and the selected row(s) using the grid's events and store them all the time. Then you could restore them in InitializeLayout.
Hi Mike,
I don't know if you're familiar with Epicor at all, but Epicor uses infragistics controls. So Epicor code in the background is actually performing a refresh of the datasource in the background when a refresh button is pressed. That's why I'm having somewhat of an issue with this because I don't have complete control over this.