本文介绍了复选框在您勾选项目时显示选择的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用winform,
我要使用哪个事件来确保在我选中已选中列表框内的项目时,在文本框中填充了这些值?
我正在使用selectedindexchanged,但是它不能正常工作.
例如,我在两个项目旁边打勾,该文本框仅显示第一个项目.
要在文本框中获得第二个被打勾的项目,我必须在复选框中单击另一个项目.
有什么想法吗?
谢谢
using winform,
Which event do I use to make sure that as I am ticking items inside a checked listbox, a textbox is populated with those values?
I am using the selectedindexchanged but it does not work accurately.
For example, I put a tick next to two items, The textbox shows only the first item.
To also get the second ticked item in th etextbox, I have to click on another item in the checklistbox.
Any thoughts please?
Thanks
推荐答案
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) {
CheckedListBox clb = (CheckedListBox)sender;
if (e.NewValue == CheckState.Checked) {
textBox1.AppendText(String.Format(Environment.NewLine + "Checking {0}", clb.Items[e.Index]));
} else {
textBox1.AppendText(String.Format(Environment.NewLine + "Unchecking {0}", clb.Items[e.Index]));
}
}
艾伦.
Alan.
这篇关于复选框在您勾选项目时显示选择的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!