[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
Re: Why do I have to manually setup form events?
Strange VB syntax...:p
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.
Re: Why do I have to manually setup form events?
Yeah i realized i was in the VB forum (old habits die hard) after I hit submit. That is why I put the edit on there.
I am not sure that I am following you there, where in the properties window do you define it??
Thanks for the quick reply btw :D
D
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 :p Use VB.Net :D
Re: Why do I have to manually setup form events?
AHA!! got it!! Thank you so much!! You earned your creds today.
Oh and as for VB, I never stop using it. But looking at the jobs that pay something decent, need to be more "Agile". :p
D