|
-
Feb 29th, 2012, 04:03 PM
#1
Thread Starter
Fanatic Member
[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
-
Feb 29th, 2012, 04:06 PM
#2
Addicted Member
Re: Why do I have to manually setup form events?
Strange VB syntax...
This is the way c# works...you have to declare the event handler. If you do it using the properties window in VS it's autogenerated in designer.cs file.
-
Feb 29th, 2012, 04:20 PM
#3
Thread Starter
Fanatic Member
-
Feb 29th, 2012, 04:24 PM
#4
Addicted Member
Re: Why do I have to manually setup form events?
There is a "thunder" on the upper side of the Properties Window.
ps. Old habits are not bad Use VB.Net
Last edited by pkarvou; Feb 29th, 2012 at 04:28 PM.
-
Feb 29th, 2012, 04:29 PM
#5
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|