本文介绍了从textbox2添加项目 - 多行到listbox1,其中items stsrts with textbox1 content? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
我想将代码从textBox2 - multiline 添加到listbox1,其中的项目以textBox1内容开头? C#
下面这段代码我用来将多行 textBox2中的项目添加到listBox1,它可以工作。
但是我想要listBox1中的项目,我从textBox2添加了textBox2中的内容。谢谢。
私人 void button1_Click( object sender,EventArgs e)
{
string [] s = Regex.Split(textBox2.Text, \\\\ n );
listBox1.Items.AddRange(s);
}
示例:
if 内容textBox1 = A
内容TextBox2 - multiline = something
something 1
2
3
结果 listBox1 = A
东西 1
某事 2
东西 3
我尝试了什么:
private void button1_Click( object sender,EventArgs e)
{
string [] s = Regex.Split(textBox2.Text, \r\\\
跨度>);
listBox1.Items.AddRange(s..StartsWith(textBox1.Text));
}
解决方案
Hello everyone.
I would like code for adding Items from textBox2 - multiline to listbox1 , where items starts with textBox1 content? C#
This code below I use to add items from the multiline textBox2 to listBox1, and it works.
But I want to items in listBox1 whose I added from textBox2 starting with content in textBox1. Thanks.
private void button1_Click(object sender, EventArgs e) { string[] s = Regex.Split(textBox2.Text, "\r\n"); listBox1.Items.AddRange(s); }
Example:
if the content textBox1 = A content TextBox2 - multiline = something something 1 something 2 something 3 The result in listBox1 = A something A something 1 A something 2 A something 3
What I have tried:
private void button1_Click(object sender, EventArgs e) { string[] s = Regex.Split(textBox2.Text, "\r\n"); listBox1.Items.AddRange(s..StartsWith(textBox1.Text)); }
解决方案
这篇关于从textbox2添加项目 - 多行到listbox1,其中items stsrts with textbox1 content? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!