dgv(DataGridView)获取选中行绑定实体数据
//获取绑定行数据
DataModel dm = dgvDatas.CurrentRow.DataBoundItem as DataModel;
private void dgvDatas_CellClick(object sender, DataGridViewCellEventArgs e) { if(e.ColumnIndex==0) { DataModel dm = dgvDatas.CurrentRow.DataBoundItem as DataModel; dm.SelCheck = !dm.SelCheck; //(sender as DataGridView).UpdateCellValue(e.ColumnIndex, e.RowIndex); SetChk(); } }
//自动创建列关闭,只显示增加列列
dgvDatas.AutoGenerateColumns = false;