[英]Add item with color to CheckBoxList or ListBox
I am adding an item from two TextBox
on Button_Click
to Checkboxlist
(or to a Listbox
) with checkedListBox1.Items.Add(textBox1.Text + textBox2.Text);
我正在将
Button_Click
上两个TextBox
的项目添加到带有checkedListBox1.Items.Add(textBox1.Text + textBox2.Text);
Checkboxlist
(或Listbox
checkedListBox1.Items.Add(textBox1.Text + textBox2.Text);
but it obviously will just add the text itself not its properties like color or font and ... . 但是它显然只会添加文本本身而不是其属性,如颜色或字体和...。
Question: How can i add items with their properties (like color and ...) to a checkboxlist or listbox? 问题:如何将具有属性(例如颜色和...)的项目添加到复选框列表或列表框?
试试这个代码:
checkedListBox1.Items.Add($"<font color=\"red\">{"String from your two fields"}</font>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.