日期:2014-05-18 浏览次数:20792 次
string Str="aa,bb,cc,"; string[] strArray = Str.ToString().Split(','); for (int k = 0; k < strArray.Length; k++) { if (strArray[k] != "") { TargetListBox.Items.Add(new ListItem(strArray[k].ToString(), strArray[k].ToString())); } }
BindingList<string> bindingStr = new BindingList<string>(); private void Form2_Load(object sender, EventArgs e) { for(int i=0;i<5;i++) { string str=i+"my"; bindingStr.Add(str); } listBox1.DataSource = bindingStr; } private void btnAddData_Click(object sender, EventArgs e) { for (int i = 0; i < 5; i++) { string str = i + "mydd"; bindingStr.Add(str); } }
------解决方案--------------------
应该不会吧,MSDN上给出的示例代码就是这样的:
Protected void Button1_Click (object sender, System.EventArgs e) { ListBox1.Items.Add(new ListItem("Carbon", "C")); ListBox1.Items.Add(new ListItem("Oxygen", "O")); }
------解决方案--------------------
按照你添加aa,bb,cc的方式添加dd,ee,ff应该不会有错吧
------解决方案--------------------
不会吧