[英]Add string before item in listbox
I have a method that fills up a listbox with properties. 我有一个用属性填充列表框的方法。 I would like to add a string before the properties value to clearify what it is.
我想在属性值之前添加一个字符串,以澄清它是什么。
listBox1.Items.Add(person.Name);
listBox1.Items.Add(person.Phone);
listBox1.Items.Add(person.City);
Is it possible to add something in the above code that will show: 是否可以在上面的代码中添加一些内容来显示:
Name: (person.Name)
Phone: (person.phone)
When the result shows in the listbox? 结果何时显示在列表框中?
Thanks! 谢谢!
怎么样
listBox1.Items.Add(string.Format("Name: {0}", person.Name));
You can use : 您可以使用 :
listBox1.Items.Add("Name :" + person.Name);
Or: 要么:
listBox1.Items.Add(String.Format("Name : {0}", person.Name);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.