c#.net的ListBox的问题????

来源:百度知道 编辑:UC知道 时间:2024/07/04 03:48:36
要如何得到ListBox.里的字符值呀???是用哪个方法呀,我用items不行呀

this.ListBox1.Items[i].Text;//得到文本,i是项的索引,索引中0开始,就是第一项为i=0
this.ListBox1.Items[i].Value;//得到值,i是项的索引
this.ListBox1.SelectedValue;//得到选中项的值
this.ListBox1.SelectedItem.Text;//得到选中项的文本
可以用如下方式得遍列全部项
string str="";
for (int i=0; i < this.ListBox1.Items.Count; i++)
{
str=str+this.ListBox1.Items[i].Text+"<br>";
}
Response.Write(str);
//你看看效果就知道了