Results 1 to 5 of 5

Thread: [RESOLVED] Why do I have to manually setup form events?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Resolved [RESOLVED] Why do I have to manually setup form events?

    I am learning c# (finally) and am using VC# 2010 Express. Why do I have to manually declare events for them to trigger?? I have created my own form that I want to use as a Splash screen (see code below).
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace LotusAnalyzer
    {
        public partial class frmSplash : Form
        {
            public frmSplash()
            {
                InitializeComponent();
                this.MouseDown += new MouseEventHandler(frmSplash_MouseDown);
            }
    
            private void frmSplash_Load(object sender, EventArgs e)
            {
            }
    
            private void frmSplash_KeyDown(object sender, KeyEventArgs e)
            {
                switch(e.ToString())
                {
                    case "enter":
                        this.Close();
                        break;
                 }
            }
    
            private void frmSplash_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.Close();
                }
            }
        }
    }
    I have a breakpoint at both the mousedown and keydown events. When I press a key they key event will not trigger, however if I mousedown it will (after I added the eventhandler part). Is this inherent to c# or the express version of 2010 or what??

    Thanks in advance!!

    D
    Last edited by dminder; Feb 29th, 2012 at 04:04 PM. Reason: I put this in the wrong forum. Please move.
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

Tags for this Thread

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