hi.
I am new to C #. I want to know is there any way to add shortcuts keys to our application buttons.
I mean if the user press 'n' key on his/her keyboard button1 will triggered it's self and perform the task behind the button.
Plz help..
hi.
I am new to C #. I want to know is there any way to add shortcuts keys to our application buttons.
I mean if the user press 'n' key on his/her keyboard button1 will triggered it's self and perform the task behind the button.
Plz help..
this.button.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.button_KeyPress);
from.cs-
private void button_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar()=='n')
{//ur code}
{}
}
Thankx A-lot Brother....
It's really helpful.
Hi
you can also use key preview of form to catch key code when any control is active. Enable Previewkeydown property and implement:
private void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
}
Hi
you can also use key preview of form to catch key code when any control is active. Enable Previewkeydown property and implement:
private void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { }
thanks,it is a great way, is there any way that i can use it in webfrom.aspx?
thanks,it is a great way, is there any way that i can use it in webfrom.aspx?
you have to enable keyPreview to True and on the keydown event of the form you should write that on what keycode it should raise this event.
ex...
if (e.KeyCode == Keys.F8)
{
write the code...
}
Also, if you include an '&' in the buttons text property, the following letter will become an accelerator and respond to Alt+Key combinations.
eg; if you create a button with the text property set to "Re&Bind Data", the buttons text will appear as "ReBind Data" and if you press Alt + B it will perform a button click.
how can i assign a shortcut to a button when the event is click...
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.