Click to See Complete Forum and Search --> : no compile error, but these events do not launch


savagerx
May 17th, 2003, 11:23 AM
pragash, may you help?


private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
MessageBox.Show("char:"+e.KeyData,"you pressed a keydown",MessageBoxButtons.OK,MessageBoxIcon.Information);

/*what happened?
if(e.Alt)
alt_label.Enabled = true;
if(e.Control)
ctrl_label.Enabled = true;

//display_textbox.Text += e.KeyCode;
*/
MessageBox.Show("keydata:" + e.KeyData,"data",MessageBoxButtons.OK,MessageBoxIcon.Hand);
}



private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
MessageBox.Show("char:" + e.KeyChar,"you pressed a button",MessageBoxButtons.OK,MessageBoxIcon.Information);
}



private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
MessageBox.Show("x","x",MessageBoxButtons.OK,MessageBoxIcon.Hand);
}

KingTermite
May 17th, 2003, 01:15 PM
Looks like you made the userdefined events, but did you add them to make sure they are used?

something like:
this.menuItemNormal.Click += new System.EventHandler(this.menuItemNormal_Click);

savagerx
May 18th, 2003, 11:55 PM
managed to solve the problem, the event handler is bind to the form, therefore I need to enable the KeyPreview property inorder for the form to capture the event which I clearly did not. Therefore the event handler do not launch. Sorry for any mis-communication.