我有一个方法:
foreach (DataGridViewColumn column in dgvGeoObjectsFirstView.Columns)
{
geoObjectsColumnsCheckedListBoxFirstView.Items.Add(column.HeaderText, column.Visible);
geoObjectsColumnsCheckedListBoxFirstView.ItemCheck += (ss, ee) =>
{
if (geoObjectsColumnsCheckedListBoxFirstView.SelectedItem != "Show")
{
if (geoObjectsColumnsCheckedListBoxFirstView.SelectedItem != null)
{
var selectedItem = geoObjectsColumnsCheckedListBoxFirstView.SelectedItem.ToString();
foreach (DataGridViewColumn column2 in dgvGeoObjectsFirstView.Columns)
{
if (column2.HeaderText == selectedItem.ToString())
{
column2.Visible = ee.NewValue == CheckState.Checked;
}
}
int currentDisplayIndex = 0;
foreach (DataGridViewColumn dataGridViewColumn in dgvGeoObjectsFirstView.Columns)
{
if (dataGridViewColumn.HeaderText == selectedItem)
{
currentDisplayIndex = dataGridViewColumn.Index;
}
}
int futureDisplayIndex = geoObjectsColumnsCheckedListBoxFirstView.SelectedIndex;
PassColumnsInFirstView(futureDisplayIndex, currentDisplayIndex);
}
}
else
{
//What can I do here to have item checked
}
};
}\
问题在于哪一个标题文本“Show”不应该被取消检查,所以我想要取消对该项目的取消检查。
也许在checkedlistbox上有一些事件?
祝你好运