blah blah blah is here! blah blah » Close

up0down
link

Hi,
I ve a login form in c# windows application . I want that after typing username and password when user
presess enter key the button click e.i submit button should invoke...
How can i do that....
tnx....

last answered 2 years ago

1 answers

up0down
link

On the events on properties window select the method key enter or enter then put your codes there to invoke the enter event

up0down
link

tnx 4 d reply...i m little new 2 c#...
Can u tell me plz how can i invoke button Click event on enter key in a TextBox...

up0down
link

Hello there..
what you can do is that in the keydown event of textbox check if the entered key is "Enter" key and if so invoke the button click event in code.
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
button1_Click(sender, e);
}
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi");
}
check out..
Shiva

up0down
link

tnx shiva....

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback