Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

C# Events [Beginner Level Tutorial]

C# Events


What Is It:
An event in C#..is well..something that happens, an action.
There are a ton of different events, in this tutorial we are going to explore 2 of them.

Getting Started:
First start by clicking on the events tab:

[IMG]http://i51.[censored].com/2le4ewi.jpg[/IMG]

After clicking this tab you will notice all of the different events for the component of your choice, for this example we are going to use a label.

Click Event:
Under my first label I double clicked the "Click" event. This event is what happens when the label is clicked.
Spoiler (Click to View)

Mouse Enter Event:
This event will execute when the mouse enters the label area.
Spoiler (Click to View)

Conclusion:
There are many many more events, you can explore all of them by viewing the events tab for your component.

Code:
Code
private void label1_Click(object sender, EventArgs e)
  {
    MessageBox.Show("I Clicked The Label!");
  }

  private void label1_MouseEnter(object sender, EventArgs e)
  {
    MessageBox.Show("Mouse Entered!");
  }
http://www.pulsecodes.info
Computer and Information Science major.
Information Technology Apprentice.
Freelance Programmer.
You should add to this, a lot more. Like for example linking events manually through coding (equivalent of 'Dim WithEvents' in VB). You should also talk about the parameters for each event handler and work on your descriptions. Event = action.
(Oct 21, 2010 12:29 AM)tflo Wrote:  You should add to this, a lot more. Like for example linking events manually through coding (equivalent of 'Dim WithEvents' in VB). You should also talk about the parameters for each event handler and work on your descriptions. Event = action.

Well, the title does say beginner level. Once I move onto more advanced tutorials I can start adding more and going into greater detail.

Thanks for your feedback though!
http://www.pulsecodes.info
Computer and Information Science major.
Information Technology Apprentice.
Freelance Programmer.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by darkdoctorJun 7, 2018 12:10 PM 1 163 Jun 7, 2018 12:10 PM
Last Post: Washi
[C#] by gigajewFeb 3, 2018 07:31 PM 0 296 Feb 3, 2018 07:31 PM
Last Post: gigajew
[.NET] by SIM-1517404Mar 7, 2017 01:21 PM 10 356 Mar 7, 2017 01:21 PM
Last Post: SIM-1517404