why CommitEdit() called three times, for a simple checkbox check changed?


  • hi friends,

    hi friends,

    please refer to my you tube video to see a video capture of what im talking about : )

    I have a simple app with a datagridview with a checkbox column. I want to check the check/uncheck status of cell so that I can color the cell if it's checked.

    I have use the CurrentCellDirtyStateChange() and CellValueChange()... what I don't understand when I simply check a checkbox why the control calls the DataGrdview.CommitEdit(...) three times?


    I use Visual studio 2012 Ultimate and SQL server 2008 developer edition!

    Monday, January 13, 2014 6:38 AM


  • Hi sniff_bits,

    To resolve your problem, you need to know how CommitEdit method and CellValueChanged event work.

    1. Before you click the CheckBox in the cell, the dataGridView1.IsCurrentCellDirty property is False.

    2. When you click the CheckBox, dataGridView1.IsCurrentCellDirty property becomes True, so the CurrentCellDirtyStateChanged event is called.

    3. In the CurrentCellDirtyStateChanged event, you call CommitEdit method. And you need to take notice that in CommitEdit method CellValueChanged event will be called.

    4. After CellValueChanged event is called, the dataGridView1.IsCurrentCellDirty property becomes False. So the CurrentCellDirtyStateChanged event will be called again. But at this time, you also need to take notice that the previous CommitEdit method is not finished yet.

    5. After the second CurrentCellDirtyStateChanged event is called, it'll return back to the previous CommitEdit method.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 14, 2014 9:05 AM