I have other controls on the form (DBgrid, TextBox,....). If the focus is on
one of this controls the "this.KeyDo wn" event is not fired when I press the
F2 key. I want the key function works even if the focus is on another
control on the form.
"Morten Wennevik" <Mo************ @hotmail.com> escreveu na mensagem
news:opryvtmk06 hntkfz@localhos t...
Not sure what you are trying to do but to capture a click event you use
this
this.button1.Cl ick += new System.EventHan dler(this.butto n1_Click);
Or if you mean when a user hits one of the Function keys (F1-F12) you can
capture it with this
this.KeyDown += new
System.Windows. Forms.KeyEventH andler(this.MyP rogram_KeyDown) ;
and in MyProgram_KeyDo wn you do
private void MyProgram_KeyDo wn(object sender,
System.Windows. Forms.KeyEventA rgs e)
{
switch(e.KeyCod e)
{
case Keys.F1:
doButton1();
break;
case Keys.F2:
doButton2();
....
}
}
private void button1_Click(o bject sender, System.EventArg s e)
{
doButton1();
}
private void doButton1()
{
// do stuff that happens when the users clicks button 1 or hits F1
}
--
Using M2, Opera's revolutionary e-mail client:
http://www.opera.com/m2/