C# 在标签中显示输出
我试图在标签中显示输出,并保留以前输入的所有数据的记录。也许在某种下拉菜单中 如何保存输入的所有数据 有人能帮我吗 谢谢C# 在标签中显示输出,c#,C#,我试图在标签中显示输出,并保留以前输入的所有数据的记录。也许在某种下拉菜单中 如何保存输入的所有数据 有人能帮我吗 谢谢 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; name
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DatabaseSQLApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void btnStrings_Click(object sender, EventArgs e)
{
string firstName;
firstName = textBox1.Text;
MessageBox.Show(firstName);
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
在btnStrings\u单击中,添加此行:
label1.Text += Environment.NewLine+firstName;
只要确保为标签留出足够的增长空间如果我理解您的意图,那么标签是错误的UI组件。从设计器上的工具箱中,将列表框拖放到应用程序中。从那里,您可以在btnStrings事件处理程序中执行此操作:
private void btnStrings_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox1.Text);
}
太好了,亚历克斯!这正是我想要实现的。我很感激。现在,我的应用程序开始工作了。这段代码看起来有点草率。如何将所有这些放在一起使代码看起来更好<代码>字符串艺术家姓名、歌曲名称、来源、Url;ArtistName=textBox1.Text;SongTitle=textBox2.Text;Source=textBox3.Text;Url=textBox4.Text;Database.Items.Add(textBox1.Text+textBox2+textBox3+textBox4)代码>