Hack Forums
[C#] C# Events [Beginner Level Tutorial] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] C# Events [Beginner Level Tutorial] (/showthread.php?tid=755425)



C# Events [Beginner Level Tutorial] - Pulser - Oct 20, 2010

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!");
  }



* - tflo - Oct 21, 2010

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.


* - Pulser - Oct 21, 2010

(Oct 21, 2010 12:29 AM)Vanquish 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!