As a user is cursoring down the grid, other controls need to respond by refetching some data for the record the cursor is on.
Since this data fetch can be time-consuming, I would like the grid event to be fired only when the user rests on record for a certain amount of time (say 500ms). That way if the user is trying to cursor down rapidly, I do not end up doing wasteful data fetches and slow the user down.
Any way to delay the grid event firing? Other suggestions?
Thanks!
Thanks Mike,
Forms.Timer did the trick. (I was stopping timer somewhere in the code)
This looks pretty much like what I meant.
One problem I notice, though, is that you are not stopping the timer inside the Elapsed event. Once you call your DisplayEventDetails, you will wait to drop the timer so it doesn't get called again until the next time the timer is started.
Also, what kind of timer are you using? Be sure to use the System.Windows.Forms.Timer.
Hi Mike
Is it something like this? my app freezes after 1 minute or something.
Murat
Private Sub UltraGrid1_AfterRowActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraGrid1.AfterRowActivate
If Not IsNothing(UltraGrid1.ActiveRow) Then
If UltraGrid1.ActiveRow.IsGroupByRow Then
txtDetails.Text = "Select a row to see details..."
Else
If araTimer.Enabled Then
araTimer.Stop()
araTimer.Start()
End If
'DisplayEventDetails()
End Sub
Private Sub araTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles araTimer.Elapsed
araTimer.Enabled = False
Try
DisplayEventDetails()
Catch ex As Exception
End Try
You can't delay the firing of events. But what I would do is use a timer.
Rather than updating your other controls inside the events of the grid, all the grid events would is start the timer. So let's say you are using AfterRowActivate in the grid. This event would check to see if the timer is already running. If not, it starts the timer. If it is already running, it would stop the timer and re-start it.
When the timer Tick event fires, you stop the timer and update your controls.