View plaincopy to clipboardprint?
1. Attribute setting checkboxcolumn
Name: cb_check
Falsevalue: false
Truevalue: True
Set readonly to false in the datagridview.
2. // single-item selection settings
Private void dgv_zy_cellcontentclick (Object sender, datagridviewcelleventargs E)
{
Int COUNT = convert. toint16 (dgv_zy.rows.count.tostring ());
For (INT I = 0; I <count; I ++)
{
{
Datagridviewcheckboxcell checkcell = (datagridviewcheckboxcell) dgv_zy.rows [I]. cells ["cb_check"]; {
Boolean flag = convert. toboolean (checkcell. value );
If (flag = true) // find the selected data row
{
Checkcell. value = false;
}
Continue;
}
}
3. Obtain the selected data
Int COUNT = convert. toint32 (dgv_zy.rows.count.tostring ());
For (INT I = 0; I <count; I ++)
{
// If the dview is editable, submit the data. Otherwise, the row in the editing status cannot be obtained.
Dgv_zy. Endedit ();
Datagridviewcheckboxcell checkcell = (datagridviewcheckboxcell) dgv_zy.rows [I]. cells ["cb_check"];
Boolean flag = convert. toboolean (checkcell. value );
If (flag = true) // find the selected data row
{
// Obtain data items from the datagridview
String z_zcode = dgv_zy.rows [I]. cells [0]. value. tostring (). Trim ();
//...................................... ..}
}
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/songkexin/archive/2009/12/03/4934143.aspx