I have an application written in VB.NET that generates an Infragistics UltraGrid containing information about companies that I get from a SQL database. When a user clicks on a row, the AfterRowActivate event is fired and more information appears for the user in the bottom half of the screen. It’s done and working nicely. This is the method that is called:
Private Sub grdCompany_AfterRowActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grdCompany.AfterRowActivate
If (Not grdCompany.ActiveRow.IsGroupByRow) Then
If (grdCompany.ActiveRow.Cells("Company_id").Text <> "") Then
FillCompanyAddressGrid()
FillCompanyDetail()
FillChildCompanyGrid()
FillPropertiesGrid()
End If
End If
End Sub
Users tend to scroll through the grid with the arrow keys quickly. So the AfterRowActivate event is getting fired off every time and it’s making unnecessary queries to the database. I want to implement a delay so that the the row has to be highlighted for about a half-second before the program starts looking in the database for more information. But I’m having trouble accomplishing this. What would be the best way to go about doing this?
Create a timer on your form
In the grid AfterRowActive function, reset the timer:
In your Timer event run the code: