已选中或未选中DataGridViewCheckBoxColumn上的C#datagridview过滤器
该数据集包含一个DataGridViewCheckBoxColumn,我希望根据3种可能性筛选视图:全部显示(复选框选中和未选中)仅显示选中和仅显示未选中已选中或未选中DataGridViewCheckBoxColumn上的C#datagridview过滤器,c#,datagrid,C#,Datagrid,该数据集包含一个DataGridViewCheckBoxColumn,我希望根据3种可能性筛选视图:全部显示(复选框选中和未选中)仅显示选中和仅显示未选中 private void listBoxBehandeld_SelectedValueChanged(object sender, EventArgs e) { string listBoxValue = "Alle"; listBoxValue = listBoxBehand
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;
您需要枚举网格中的行,以便根据案例选择进行筛选 这里有一个例子
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
}