DataGridView CheckBox column doesn't apply changes to the underlying bound object

后端 未结 1 905
梦毁少年i
梦毁少年i 2020-12-02 02:55

I have a list of Record objects that serve as rows in my DataGridView. Each Record has a new bool value Helped. Sure enough, this new

相关标签:
1条回答
  • 2020-12-02 03:18

    As it stands currently, when this box is checked it doesn't seem to change the value of Helped bool in the corresponding Record.

    The changes which you make on a cell of DataGridView, doesn't commit immediately to the data source until you finish editing the cell, then changes will be pushed to data source. If for any reason you want to push changes sooner, you can call:

    dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
    

    For example you can do that in CellContentClick event of your DataGridView to push check box value to the underlying property of data source.

    0 讨论(0)
提交回复
热议问题