Windows Forms Textbox Enter key

c#, textbox, winforms

Solution

you already have a button as well like this

button.Click += new EventHandler(Submit); 

if you want to call this function you can do this

button.PerformClick();  //this will call Submit you specified in the above statement

Problem

I have a TextBox, but I can't find any source explaining how to call a function when a button is pressed down. ``` public Simple() { Text = "Server Command Line"; Size = new Size(800, 400); CenterToScreen(); Button button = new Button(); TextBox txt = new TextBox (); txt.Location = new Point (20, Size.Height - 70); txt.Size = new Size (600, 30); txt.Parent = this; button.Text = "SEND"; button.Size = new Size (50, 20); button.Location = new Point(620, Size.Height-70); button.Parent = this; button.Click += new EventHandler(Submit); } ``` Some sources tell me to use a function, but I don't understand how it is going to get called.

Original source