以编程方式选择 winforms 复选框列表中的项目
我不知道如何以编程方式选择复选框列表中的项目。
这种方法无法编译,但我想向您展示我想要得到的结果。
public ColumnsSelector(Dictionary<string, bool> dataPropertyNames)
: this()
{
foreach (var item in dataPropertyNames)
{
checkedListBox1.Items.Add(item.Key);
checkedListBox1.Items[checkedListBox1.Items.IndexOf(item.Key)].Checked = item.Value;
}
}
你如何强制解决这个问题?
I can't figure out how to programmatically select items in checkboxlist.
This method of cource doesn't compile, but I want to show you what a result I want to get.
public ColumnsSelector(Dictionary<string, bool> dataPropertyNames)
: this()
{
foreach (var item in dataPropertyNames)
{
checkedListBox1.Items.Add(item.Key);
checkedListBox1.Items[checkedListBox1.Items.IndexOf(item.Key)].Checked = item.Value;
}
}
How do you force with this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 CheckedListBox.SetItemCheckState:
有效对于已检查、未检查和不确定。您还可以使用 CheckedListBox.SetItemChecked :
Use CheckedListBox.SetItemCheckState:
which works for checked, unchecked, and indeterminate. You can also use CheckedListBox.SetItemChecked:
或者只是
or just