DataGridView checkbox column - value and functionality

后端 未结 11 1760
一向
一向 2020-11-28 12:17

I\'ve added a checkbox column to a DataGridView in my C# form. The function needs to be dynamic - you select a customer and that brings up all of their items that could be s

11条回答
  •  猫巷女王i
    2020-11-28 12:55

    If you have a gridview containing more than one checkbox .... you should try this ....

    Object[] o=new Object[6];
    
    for (int i = 0; i < dgverlist.RowCount; i++)
    {
        for (int j = 2; j < dgverlist.ColumnCount; j++)
        {
            DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
            ch1 = (DataGridViewCheckBoxCell)dgverlist.Rows[i].Cells[j];
    
            if (ch1.Value != null)
            {
               o[i] = ch1.OwningColumn.HeaderText.ToString();
    
                MessageBox.Show(o[i].ToString());
            }
        }
    }
    

提交回复
热议问题