none
CellValueChanged fires up even after DataBindingComplete event RRS feed

  • Question

  • I add handler to CellVlaueChanged event of datagridview after DataBindingComplete is finished. However for some reason my CellValueChanged handler is fireup for all of my rows which i do not understand. From my understanding when data is load so DataBindingComplete is raised and i hook handler there CellValueChanged event shouldn't be raised untill user change the content of some cell. What i am doing wrong?

    Private Sub dataGridView1_DataBindingComplete(ByVal sender As Object, _
            ByVal e As DataGridViewBindingCompleteEventArgs) _
            Handles dataGridView1.DataBindingComplete
            
        ...
            
        RemoveHandler dataGridView1.CellValueChanged, AddressOf SuperGridControl1CellValueChanged
        AddHandler dataGridView1.CellValueChanged, AddressOf SuperGridControl1CellValueChanged
            
    End Sub

    Wednesday, October 11, 2017 9:19 AM

All replies

  • The event is not AllDataBindingComplete

    But you handle it like that.

     

     

    Success
    Cor

    Wednesday, October 11, 2017 10:11 AM
  • what should i do then?
    Wednesday, October 11, 2017 10:31 AM
  • It seems to me that you load from somewhere the data to your datagridview. 

    On that place you can use in the begin of the method that remove handler and set it at the end again. 

    First removing it and then in the next statement setting it, makes no sence. 

    Be aware that with this you must not use the handles clause for the cell change event.


    Success
    Cor

    Wednesday, October 11, 2017 10:37 AM
  • the remove is just in case, i do not want adding handler more than once so want to make sure if there is already handler to remove it and then add because from my knowledge it could be that handler will be asociated many times means method could be raised that count
    Wednesday, October 11, 2017 10:56 AM
  • the remove is just in case, i do not want adding handler more than once so want to make sure if there is already handler to remove it and then add because from my knowledge it could be that handler will be asociated many times means method could be raised that count

    Jimmy,

    A programmer knows what a program does. Making plasters to solve unknown things, means that your program is unpredictable and probably should be made new.

    Be aware a handler handles events, it does not raise them. 


    Success
    Cor

    Wednesday, October 11, 2017 11:20 AM
  • Hi Jimmy,

    According to your code and description, you remove datagridview.CellValueChanged event in the datagridview.DataBindingComplete event. At my side, the datagridview.CellValueChanged is not fired up when the datagridview.DataBindingComplete event raise, so I don't know why you want to remove this event and then add this event again?

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 12, 2017 3:21 AM
    Moderator