Datagridview is the most complex control in. net. It is very difficult to compile a universal Datagridview (similar to the datatable in JSF) because of various table formats.
In the Datagridview, you can program rows, columns, and cells. For example, you can insert a drop-down list, check box, edit box, single-dataset, and other controls into a row. Each control starts with a dview. For example, the singleton class is DataGridViewCheckBoxCell.
DataGridViewCheckBoxCell has some disgusting attributes that have plagued me for a long time. I will explain them in detail below.
FormattedValue attributes:
You may have become accustomed to using an intuitive statement such as checked = true or checked = false to obtain the checkbox value. However, the DataGridViewCheckBoxCell does not have the checked attribute, but uses a more complex FormattedValue.
EditedFormattedValue attributes:
The status of the current checkbox, whether it is a "validation value" or not ". In our impression, the checkbox is only true or false. What is "validation value? The check value indicates that the current checkbox value is returned no matter whether the user has left the cell (that is, the final status of the cell. At first glance, I was even more confused. For example:
(1) When the checkbox is not selected, the user clicks it, so the checkbox displays the check status.
At this time, EditedFormattedValue = true, but FormattedValue = false, because the user does not "Confirm" this value, the checkbox is still in the editing status;
(2) When the checkbox is selected at the beginning, the user clicks it, so the checkbox displays the unchecked status, and then the user clicks another cell.
In this case, EditedFormattedValue = false, but FormattedValue = false. This is because the user leaves the cell and the user has "Confirmed" The value. The checkbox is no longer in the editing status, and its EditedFormattedValue = FormattedValue
In this case, EditedFormattedValue = false, but FormattedValue = false. This is because the user leaves the cell and the user has "Confirmed" The value. The checkbox is no longer in the editing status, and its EditedFormattedValue = FormattedValue
[Csharp]
For (int I = 0; I <dataGridView1.Rows. Count; I ++)
{
Maid = (maid) maid [I]. Cells [Column_Id.Index];
If (chkBoxCell! = Null & (bool) chkBoxCell. EditingCellFormattedValue = true | (bool) chkBoxCell. FormattedValue = true ))
{
}
}
For (int I = 0; I <dataGridView1.Rows. Count; I ++)
{
Maid = (maid) maid [I]. Cells [Column_Id.Index];
If (chkBoxCell! = Null & (bool) chkBoxCell. EditingCellFormattedValue = true | (bool) chkBoxCell. FormattedValue = true ))
{
}
}