I don't know if you have any experience like this. When you click or cancel the checkbox column of the datagridview dview, it is difficult to determine whether the status is selected or not, which makes it difficult to perform other operations, the solution is listed below:
The CurrentCellDirtyStateChanged and CellValueChanged events of the dview are mainly used.
The CurrentCellDirtyStateChanged event submits changes to the checkbox status.
The CellValueChanged event is used to perform other operations after the status is submitted, that is, after the cell value is changed. Here, the true or false status of the checkbox column is set as the tooptiptext attribute to the button column in the same row.
CurrentCellDirtyStateChanged Event code:
Code
Private void dataGridView1_CurrentCellDirtyStateChanged (object sender, EventArgs e)
{
If (this. dataGridView1.IsCurrentCellDirty) // you have not submitted any more. // modify
{
This. Maid. Commit );
}
}
CellValueChanged Event code:
Code
Private void maid (object sender, maid e)
{
If (this. dataGridView1.Columns [e. ColumnIndex]. Name. Equals ("gender "))
{
Maid cell dgvButtonCell = this. Maid [e. RowIndex]. Cells ["btn"] as maid cell; // get the button Column cell
Maid cell dgvCheckBoxCell = this. Maid [e. RowIndex]. Cells [e. ColumnIndex] as maid cell; // get the cell in the checkbox Column
DgvButtonCell. ToolTipText = dgvCheckBoxCell. Value. ToString (); // Value assignment
}
}