來自服務器的數據需要拆分爲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]。它假設打印.. asd在listbox1,123在listbox2,12在listbox3 ..但在我的代碼我把所有的結果在listbox1做檢查。所以,在listbox2假設打印出asd –