如何在标签框中显示选中的项目 [英] how to display checked items in label box

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

问题描述

如何在checklistbox中获取已检查的项目并将其显示在标签框中。

并将逗号放在彼此之后



ex:



[]动作

[x]剧情

[x]恐怖

[]科幻片

[x]惊悚片



label =戏剧,Horro,Thriller

解决方案

您可以使用 CheckedListBox.CheckedItems [ ^ ] - 属性。链接页面的底部有一个示例。然后加入这些字符串,例如,使用 String.Join(..) [ ^ ](在底部也有一个例子)为分隔符指定,并将结果字符串分配给 Label.Text [ ^ ] - 标签的属性。

how do i get checked items in checklistbox and display it in label box.
and put comma after each other

ex:

[] Action
[x] Drama
[x] Horror
[] Sci-fi
[x] Thriller

label = Drama, Horro, Thriller

解决方案

You can get the checked items with the CheckedListBox.CheckedItems[^]-Property. The linked page has an example at the bottom. Then join these strings, for example, with String.Join(..)[^] (also has an example at the bottom) specifying ", " for the separator and assign the result string to the Label.Text[^]-Property of your label.


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

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