gpt4 book ai didi

c# - 在两行列表框中从文本框中添加相同的字符串?

转载 作者:太空宇宙 更新时间:2023-11-03 21:00:44 25 4
gpt4 key购买 nike

是否可以在列表框的两行中添加在texbox中键入的相同字符串,如下图所示?

enter image description here

private void metroButton10_Click(object sender, EventArgs e)
{
listBox2.Items.Add("Next station: " + metroTextBox1.Text);
listBox2.Items.Add(Environment.NewLine)
metroTextBox1.Clear();
listBox2.SelectedIndex = 0;
}

最佳答案

使用下面的代码。

 private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("Next Station: "+textBox1.Text);
listBox1.Items.Add("Station: " + textBox1.Text);
}

你不能使用新行。因为列表框可以在一行中包含一个项目。

关于c# - 在两行列表框中从文本框中添加相同的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45795832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com