DataBindingComplete firing on form Visibility change
-
I have a DataGridView that runs hidden in the system tray, and when I unhide it the DataBindingComplete event fires anywhere between 3 and 8 times for the datagridview on the form, drastically slowing down the application. Is there something wrong with the databinding event? MSDN states that changes in the datasource will cause this event to fire. Why is changing the visibility firing it? This is the code for the system tray double click event.
Private Sub sysTray_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles sysTray.MouseDoubleClick
Me.Visible = Not Me.Visible
Me.ShowInTaskbar = Me.Visible
Me.WindowState = FormWindowState.Normal
End SubAnd here is the code in the databindingcomplete event:
Private Sub dgErrors_DataBindingComplete(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles dgErrors.DataBindingComplete
Debug.WriteLine("Fired event: dgErrors_DataBindingComplete: by " + CType(sender, Control).Name + " event Type: " + e.ListChangedType.ToString())
End SubThe code produces the following output when double clicking on the system tray icon:
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: ResetI dont understand why it is firing 7 times. In fact I don't understand why it is firing at all. I need another event for the datagrid that fires only once, or I need to fix what is happening here somehow, any suggestions? Thanx in advance for answers
-
I have a DataGridView that runs hidden in the system tray, and when I unhide it the DataBindingComplete event fires anywhere between 3 and 8 times for the datagridview on the form, drastically slowing down the application. Is there something wrong with the databinding event? MSDN states that changes in the datasource will cause this event to fire. Why is changing the visibility firing it? This is the code for the system tray double click event.
Private Sub sysTray_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles sysTray.MouseDoubleClick
Me.Visible = Not Me.Visible
Me.ShowInTaskbar = Me.Visible
Me.WindowState = FormWindowState.Normal
End SubAnd here is the code in the databindingcomplete event:
Private Sub dgErrors_DataBindingComplete(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles dgErrors.DataBindingComplete
Debug.WriteLine("Fired event: dgErrors_DataBindingComplete: by " + CType(sender, Control).Name + " event Type: " + e.ListChangedType.ToString())
End SubThe code produces the following output when double clicking on the system tray icon:
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: Reset
Fired event: dgErrors_DataBindingComplete: by dgErrors event Type: ResetI dont understand why it is firing 7 times. In fact I don't understand why it is firing at all. I need another event for the datagrid that fires only once, or I need to fix what is happening here somehow, any suggestions? Thanx in advance for answers
-
bigbrownbeaver wrote:
Why is changing the visibility firing it?
I have no idea. Have you looked at the call stack?
led mike
I just looked there, and I found what is causing it, but I still don't know why... It's the ShowInTaskbar property thats causing this to happen. What puzzles me the most is probably that the property is only changed once, but it triggers the DataBindingComplete event 7 times. I have commented out that line until I have some free time figure out what exactly is casuing it, for now people are just going to have to live with the application in their system tray. Thanks for the help mike.