本文介绍了将文本框值传递到列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
今天早些时候,我问如何将列表框项目传递到文本框,穆罕默德·米特瓦利(Mohamed Mitwalli)再次解决了该问题(再次感谢),但是现在我有疑问如何将相同的值传递回列表框
在那个较早的问题中,我有列表框项目1和2,并且像这样1,2传递到了文本框,但现在我想将其传递回列表框,以便在列表框中有两个项目1和2
Earlier today I asked how to pass listbox items to textbox and Mohamed Mitwalli solved it (THANKS AGAIN) but now I have question how to pass that same value back to listbox
in that earlier problem I had listbox items 1 and 2 and that was passed into textbox like this 1,2 but now I want to pass that back to listbox so that in listbox I have two items 1 and 2
推荐答案
string[] values = textBox.Text.Spilit(',');
foreach (string value in values)
{
if(value.Trim()=="")
continue;
listBox.Items.Add(value.Trim());
}
this will help you.
string[] values = textBox.Text.Spilit(',');
foreach (string value in values)
{
listBox.Items.Add(value.Trim());
}
这篇关于将文本框值传递到列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!