DataGridView 中第一列"chk"为
DataGridViewCheckBoxColumn如何在初始化的时候让"chk"列 为默认选中打勾的状态 if (dgvProperties.Rows[i].Cells["chk"].Value == null)
{
dgvProperties.Rows[i].Cells["chk"].Value = true ;
} 这样是不可以的而DataGridViewCheckBoxColumn1.checked 这样的属性又不存在
DataGridViewCheckBoxColumn如何在初始化的时候让"chk"列 为默认选中打勾的状态 if (dgvProperties.Rows[i].Cells["chk"].Value == null)
{
dgvProperties.Rows[i].Cells["chk"].Value = true ;
} 这样是不可以的而DataGridViewCheckBoxColumn1.checked 这样的属性又不存在
{
string ControlName = this.Controls[j].GetType().ToString();
if ("CheckBox".Equals(ControlName))
{
CheckBox ch = CheckBox ch = (CheckBox)Controls[j]; if (ch.Name = "ch" + j.ToString())//ch1,ch2,ch3....
{
if (ch.Checked == true)//被选中的
{ }
}
}
}给你个小例子,参考下
dataGridView1.Rows.Add(true);
如果要定位到某行的话这样写
需要先实例化
DataGridViewCheckBoxCell dc3 ;
dc3 = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[7];
dc3.Value = true;
不明白可以到我的blog
http://hi.baidu.com/iaskall
ColumnCheckBox.DefaultCellStyle.NullValue = true;
{
try
{
DataGridView curDgv = (DataGridView)sender;
for (int i = 0; i < curDgv.Rows.Count; i++)
{
curDgv.Rows[i].Cells["chk"].Value = true;
}
}
catch
{
}
}
在dgv 绑定完成后,做判断
谢谢各位,马上揭帖