数据集包含一个DataGridViewCheckBoxColumn,我想过滤3种可能的视图:show all(复选框已选中和未选中)仅显示已选中且仅取消选中
private void listBoxBehandeld_SelectedValueChanged(object sender, EventArgs e)
{
string listBoxValue = "Alle";
listBoxValue = listBoxBehandeld.GetItemText(listBoxBehandeld.SelectedItem);
switch (listBoxValue)
{
case "Alle":
//Show checked and unchecked
break;
case "Ja":
//show checked
break;
case "Nee":
//show unchecked
}
break;
}
dataGridView.DataSource = meldingenBindingSource;
答案 0 :(得分:0)
您需要根据案例选择枚举网格中的行进行过滤。
foreach (DataGridViewRow row in dataGridView.Rows)
{
//Get the appropriate cell using index, name or whatever and cast to DataGridViewCheckBoxCell
DataGridViewCheckBoxCell cell = row.Cells[colCheck] as DataGridViewCheckBoxCell;
//Compare to the true value because Value isn't boolean
if (cell.Value == cell.TrueValue)
//The value is true
}