Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. DataBindingComplete firing on form Visibility change

DataBindingComplete firing on form Visibility change

Scheduled Pinned Locked Moved Windows Forms
questiondebugginghelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bigbrownbeaver
    wrote on last edited by
    #1

    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 Sub

    And 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 Sub

    The 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: Reset

    I 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

    L 1 Reply Last reply
    0
    • B bigbrownbeaver

      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 Sub

      And 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 Sub

      The 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: Reset

      I 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

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      bigbrownbeaver wrote:

      Why is changing the visibility firing it?

      I have no idea. Have you looked at the call stack?

      led mike

      B 1 Reply Last reply
      0
      • L led mike

        bigbrownbeaver wrote:

        Why is changing the visibility firing it?

        I have no idea. Have you looked at the call stack?

        led mike

        B Offline
        B Offline
        bigbrownbeaver
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups