每次单击Enter时,他都会删除文本框,并将单词的文本添加到列表框中?
答案 0 :(得分:2)
基本上,以 REALLY BASIC 方式完成您要求的Windows Forms App的代码将是以下内容:
using System.Windows.Forms;
namespace WindowsFormsApp1 {
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 13) //checks if "enter" was pressed
{
listBox1.Items.Add(textBox1.Text);//adds the text to the list
textBox1.Clear(); //clear the text of the textbox
}
}
} }