复选框在您勾选项目时显示选择的项目 [英] checklistbox show select items as you tick items

查看:231
本文介绍了复选框在您勾选项目时显示选择的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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

推荐答案

我会尝试 ^ ].这个名字散发出来,你不觉得.

是否有可能使选定的项目和选中的项目混在一起?这对我有用

I''d try the ItemCheck event[^]. The name gives it away, don''t you think.

Is it possible you are getting selected items and checked items mixed up? This works for me

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.


使用CheckedListBox的OnClick事件
use OnClick event of CheckedListBox


我尝试了click事件,但仍然无法完成我的工作.
也就是说,如果我勾选两个项目,则当我单击控件中的另一个项目时,仅在文本框中显示第二个项目.
I tried the click event but it still does NOT do what I am after.
i.e. if I tick two items, the second item only is shown in the textbox if I click on another item in the control.


这篇关于复选框在您勾选项目时显示选择的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆