Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在CheckedListBox C#Windows窗体中实现添加、编辑、删除_C#_.net_Winforms_Checkedlistbox - Fatal编程技术网

如何在CheckedListBox C#Windows窗体中实现添加、编辑、删除

如何在CheckedListBox C#Windows窗体中实现添加、编辑、删除,c#,.net,winforms,checkedlistbox,C#,.net,Winforms,Checkedlistbox,目前,我有此代码在CheckedListBox中添加一项 var items = DomainGroupCheckedListBox.Items; items.Clear(); items.Add(result[DropDownDomainIDs.SelectedIndex]); 但我将如何实现这样的目标 这意味着,如果用户单击编辑,那么它可以编辑选中的字段如果您希望在用户单击编辑时保存CKECEDBUTTON的状态,则可以创建一个on_click事件,触发保存列表中每个元素的状态 下面是如

目前,我有此代码在CheckedListBox中添加一项

var items = DomainGroupCheckedListBox.Items;
items.Clear();
items.Add(result[DropDownDomainIDs.SelectedIndex]);
但我将如何实现这样的目标


这意味着,如果用户单击编辑,那么它可以编辑选中的字段

如果您希望在用户单击编辑时保存CKECEDBUTTON的状态,则可以创建一个on_click事件,触发保存列表中每个元素的状态

  • 下面是如何创建等待点击按钮的事件:

  • 创建事件时,代码中将生成一个新的函数,但不要更改其参数。你的代码看起来像什么

  • 私有无效按钮单击(对象发送者,事件参数e) { foreach(项目中的var项目) { bool itemschecked=项目。已检查; //现在您知道该项是否已选中 } }
    创建一个包含
    文本框
    确定
    取消
    按钮的对话框。然后将选中项的文本传递给对话框并显示对话框。然后检查对话框结果是否为
    OK
    将输入的值设置为选中索引处的项。好主意,我将实现它。包含文本框和“确定”和“取消”按钮的对话框应采用单独的形式?是的,这是一种新形式。OK。谢谢你的见解 private void ButtonEdit_Click(object sender, EventArgs e) { foreach (var item in items) { bool itemIsChecked = item.Checked; // Now you know that this item is checked or not } }