Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TextBox tb = new TextBox();
- Button btn = new Button { Dock = DockStyle.Bottom };
- btn.Click += delegate { Debug.WriteLine("Submit: " + tb.Text); };
- Application.Run(new Form { AcceptButton = btn, Controls = { tb, btn } });
- TextBox tb = new TextBox();
- Button btn = new Button { Dock = DockStyle.Bottom };
- btn.Click += delegate { Debug.WriteLine("Submit: " + tb.Text); };
- tb.KeyDown += (sender,args) => {
- if (args.KeyCode == Keys.Return)
- {
- btn.PerformClick();
- }
- };
- Application.Run(new Form { Controls = { tb, btn } });
- void TextBox1_GotFocus(object sender, EventArgs e)
- {
- this.AcceptButton = ProcessTextBox1;
- }
- void TextBox2_GotFocus(object sender, EventArgs e)
- {
- this.AcceptButton = ProcessTextBox2;
- }
Add Comment
Please, Sign In to add comment