[英]checkedlistbox item check to listbox
I'm using this code to pass the selected item to a listbox called SelectedList. 我正在使用此代码将选定的项目传递到名为SelectedList的列表框。 The problem is that nothing happens when I checked an item of my chekedlistbox, what can be the problem here? 问题是,当我检查我的chekedlistbox中的项目时,什么也没发生,这可能是什么问题?
public void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (e.NewValue == CheckState.Checked)
{
selectedList.Items.Add(checkedListBox1.SelectedItem.ToString());
}
else
{
selectedList.Items.Remove(checkedListBox1.SelectedItem.ToString());
}
}
public void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
selectedList.Text = checkedListBox1.SelectedItem.ToString();
}
解决该问题的方法是在事件选项卡中未激活checkedListBox1_ItemCheck事件,这就是编译器在调试过程中未考虑它的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.