This problem occurs during development (winform). C # how to determine whether the checkbox column in The dview datagriis selected, and the cause of the error is C # The type is strictly determined. To avoid detours in the future, let me talk about my ideas and hope to help you.
For (int I = 0; I <dataGridView1.Rows. Count; I ++)
{
If (bool) dataGridView1.Rows [I]. Cells [0]. EditedFormattedValue = true)
{
// TODO
}
}
========================================================== ========================================================== ===
Private void PrintInFo (){
Try
{
Int count = 0;
// Used to save the selected checkbox quantity
// DG_List is the datagridview Control
For (int I = 0; I <DG_List.RowCount; I ++)
{
If (DG_List.Rows [I]. Cells [0]. EditedFormattedValue. ToString () = "True ")
// Check whether the check box is selected.
{
Count ++;
}
}
If (count = 0)
{
MessageBox. Show ("Please select at least one piece of data! "," Prompt ");
Return;
}
Else
{
If (MessageBox. Show (this, "Do you want to update the data? "," Prompt ", MessageBoxButtons. YesNo, MessageBoxIcon. Information). ToString () =" Yes ")
{
For (int I = 0; I <count; I ++)
{
Ps. pexcute ("update cf_prj_certi set FIsPrint = '" + number + "'where fid ='" + DG_List.Rows [I]. cells ["fnn"]. value. toString () + "'"); // Execute SQL
}
} Else
{
Return;
}
}
} Catch (Exception ex)
{
MessageBox. Show (ex. ToString ());
} This. ShowInfo (); // rebind the datagridview.
}
========================================================== =
Click the CellMouseClick event in the dataGridView1 event.
Private void maid (object sender, maid e)
{
If (e. ColumnIndex = 6)
{
DataGridView1.Rows [e. RowIndex]. Cells [e. ColumnIndex]. Value = true;
}
}
This problem occurs during development (winform). C # how to determine whether the checkbox column in The dview datagriis selected, and the cause of the error is C # The type is strictly determined. To avoid detours in the future, let me talk about my ideas and hope to help you.
For (int I = 0; I <dataGridView1.Rows. Count; I ++)
{
If (bool) dataGridView1.Rows [I]. Cells [0]. EditedFormattedValue = true)
{
// TODO
}
}