CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Torture chamber
    Posts
    132

    Unhappy no compile error, but these events do not launch

    pragash, may you help?

    [SOURCE]
    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);
    }
    [/SOURCE]

    [SOURCE]
    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);
    }
    [/SOURCE]
    end------------------------------
    Programmers aren't born, but are made from hardwork, effort and time.
    To be a good one, requires more effort and hardwork.
    Therefore N quality programmer = (N*hardwork)+(N*effort)+(N*time)

  2. #2
    Join Date
    Jul 2002
    Location
    Seattle Area, WA
    Posts
    241
    Looks like you made the userdefined events, but did you add them to make sure they are used?

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

  3. #3
    Join Date
    Oct 2002
    Location
    Torture chamber
    Posts
    132
    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.
    end------------------------------
    Programmers aren't born, but are made from hardwork, effort and time.
    To be a good one, requires more effort and hardwork.
    Therefore N quality programmer = (N*hardwork)+(N*effort)+(N*time)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured