【发布时间】:2012-06-26 09:24:40
【问题描述】:
来自服务器的数据需要拆分成ListBox。下面是我的代码。
private void button1_Click_2(object sender, EventArgs e)
{
//String[] arr = new String[1];
listBox1.Items.Clear();
listBox1.Items.Add("No Of Items=" + _server.Q.NoOfItem.ToString());
for (int i=0; i <= _server.Q.NoOfItem - 1; i++)
{
listBox1.Items.Add( _server.Q.ElementAtBuffer(i).ToString());
}
listBox2.Items.Add("No Of Items=" + _server.Q.NoOfItem.ToString());
for (int i = 0; i <= _server.Q.NoOfItem - 1; i++)
{
String words = _server.Q.ElementAtBuffer(i).ToString();
listBox2.Items.Add(words.Split(new char[] { '[' , ']', ' '}));
}
listBox1 应该显示从服务器检索到的所有数据。 listBox2 应该显示已拆分的数据。
如何做到这一点?
【问题讨论】:
-
您当前的代码发生了什么?你想要什么输出?
-
我的输出:name[asd] id[123] age[12]。它假设在 listbox1 中打印 .. asd,在 listbox2 中打印 123,在 listbox3 中打印 12 ..但是在我的代码中,我将所有结果放在 listbox1 中进行检查。所以,在 listbox2 中假设打印出 asd