当我在文本框中输入内容时,我想要 运行 (事件发生)的方法

I want method to run (event to occur) while i am typing something in textbox

我想要方法 运行(事件发生),同时我在文本框中键入内容(我不想单击按钮)例如,我有一个相同形式的文本框和列表框,而我我在文本框中写文本,它应该同时在列表框中打印出来而不用点击按钮

利用 TextBox 控件的 TextChanged event.

This event is raised if the Text property is changed by either a programmatic modification or user interaction. For more information about handling events, see Handling and Raising Events.

您可以通过属性列表访问它,或者您可以在 InitializeForm_Load 甚至在 Form 构造函数中创建它,使用:

textBox1.TextChanged += textBox1_TextChanged;

private void textBox1_TextChanged(object sender, EventArgs e) { }

为您的文本框使用文本更改事件 Text Changed event