I have other controls on the form (DBgrid, TextBox,....). If the focus is on
one of this controls the "this.KeyDown" 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:opryvtmk06hntkfz@localhost...
Not sure what you are trying to do but to capture a click event you use
this
this.button1.Click += new System.EventHandler(this.button1_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.KeyEventHandler(this.MyProgra m_KeyDown);
and in MyProgram_KeyDown you do
private void MyProgram_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
switch(e.KeyCode)
{
case Keys.F1:
doButton1();
break;
case Keys.F2:
doButton2();
....
}
}
private void button1_Click(object sender, System.EventArgs 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/