Extended Textbox
-
I extend a textbox for keypress event. a form includes one extended textbox and a button which is accept button of form. But when after editing text when u press Enter key , doesnt raise button_click event. How can pass this event to FORM when user press ENTER key after edit text.
-
I extend a textbox for keypress event. a form includes one extended textbox and a button which is accept button of form. But when after editing text when u press Enter key , doesnt raise button_click event. How can pass this event to FORM when user press ENTER key after edit text.
if your case what i understand that after the user enters or modify the text he/she will press enter and the form should the run the code for that button . so Simply select the form in the design Area and click F4 for properties the at go to Accept Button And choose your button. as simple as that if this was your case .
-
if your case what i understand that after the user enters or modify the text he/she will press enter and the form should the run the code for that button . so Simply select the form in the design Area and click F4 for properties the at go to Accept Button And choose your button. as simple as that if this was your case .
Make sure in the Form properties the property KeyPreview is set to true. of if you can't find it there go to where the Form properties are initialized and put this code there: this.KeyPreview = true; //"this" refers to the Form //or KeyPreview = true; //but make sure the code is in the Form class //otherwise you'll get an error -- Don't worry about the world coming to an end today. It's already tomorrow in Australia --
-
if your case what i understand that after the user enters or modify the text he/she will press enter and the form should the run the code for that button . so Simply select the form in the design Area and click F4 for properties the at go to Accept Button And choose your button. as simple as that if this was your case .
-
You got me wrong Form has a button and ExtendedTextbox textBox Button is already accept button of Form ExtendedTextbox has keypress event to control entry ,So if u press ENTER, this event handles enter key.
I understand that, but you need to have KeyPreview = true; to be able to assign the AcceptButton property to a button for it to work without any extra code. (If the KeyPreview property is set to false, your case will only work if the only control on the Form is the button.) This is part of the code and it doesn't include the Form initialization where you need to put KeyPreview = true; This is all you need to be able to let's say write something in a textfield, press ENTER and even if your text still has focus it will work. But if you don't have the KeyPreview set to true, it will not. //********************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace ButtonPressedCsharpDELETETHIS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = "Button is pressed"; } } } //******************************************* -- Don't worry about the world coming to an end today. It's already tomorrow in Australia --
-
I understand that, but you need to have KeyPreview = true; to be able to assign the AcceptButton property to a button for it to work without any extra code. (If the KeyPreview property is set to false, your case will only work if the only control on the Form is the button.) This is part of the code and it doesn't include the Form initialization where you need to put KeyPreview = true; This is all you need to be able to let's say write something in a textfield, press ENTER and even if your text still has focus it will work. But if you don't have the KeyPreview set to true, it will not. //********************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace ButtonPressedCsharpDELETETHIS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = "Button is pressed"; } } } //******************************************* -- Don't worry about the world coming to an end today. It's already tomorrow in Australia --
-
I extend a textbox for keypress event. a form includes one extended textbox and a button which is accept button of form. But when after editing text when u press Enter key , doesnt raise button_click event. How can pass this event to FORM when user press ENTER key after edit text.