PDA

View Full Version : سوال: checkbox type in Data grid view



Mahdad999
یک شنبه 29 خرداد 1390, 01:13 صبح
باسلام خدمت اساتید محترم،
میخواستم بدونم چطور میشه چک کرد که در یک Datagrid view که یکی از ستون هاش از نوع checkbox هستش کدوم چک باکس (ها) تیک خورده؟
راستش من از کد:



foreach (CheckBox cb in clmnDelete)
{
if(cb.Checked == true)
if (MessageBox.Show("پیغام")
== DialogResult.OK)
{
{
استفاده کردم ولی error زیر رو میده:
Error 1 foreach statement cannot operate on variables of type 'System.Windows.Forms.DataGridViewCheckBoxColumn' because 'System.Windows.Forms.DataGridViewCheckBoxColumn' does not contain a public definition for 'GetEnumerator' formContractor.cs 109 13 Application

ممنونم اگه راهنمایی بفرمایید.

mmd2009
یک شنبه 29 خرداد 1390, 02:57 صبح
با سلام.

از دستور زیر میتونی استفاده بکنی :


foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[1].Value != null)
{
if ((Boolean)row.Cells[1].Value)
{
listBox1.Items.Add(row.Cells[0].Value);
}
}
}