Begin by starting Visual Studio and creating a new Windows Forms project called ''CSharpEvents''. When the project has been created select the Form in the design area and add a Label control. In the properties panel change the name of the label to ''infoLabel''.
Select the Form again and click on the lightening lightning bolt button at the top of the properties panel. This will display a list of available events for the Form object. Scroll down the list and double click on the ''MouseClick'' event:
[[Image:c_sharp_mouseclick_event.jpg|Selecting a MouseClick event on a Windows Form]]
Once the ''MouseClick'' event has been select selected by double clicking , the code for the event will be displayed. This code will appear as follows:
<pre>
Now that we have a simple Form design and the outline of a MouseClick event handler the next step is to start interrogating the ''e'' event parameter object to learn a little more about the event that triggered to the call the ''Form1_MouseClick()'' event handler.
Within the code outline for the methods , type ''e.''followed by a dot (.). Visual Studio will then popup a list of available properties for this event object.
[[Image:c_sharp_mouse_click_properties.jpg|A list of properties available from a C# MouseClick event parameter]]
A number of useful properties are available to us in our C# code within this event handler. For the purposes of this example we are interesting in finding out which mouse button was pressed by the user and the X and Y co-ordinates. As such, we need to access the ''Button'', ''X'' and ''Y'' properties.
The X and Y properties are easy to handle since they are simply integer values indicating where the moise mouse pointer was in the form when the user clicked a mouse button. As such we can simplay simply take these values and display them in our ''infoLabel'' control:
<pre>
</pre>
After entering the above code press the '''F5''' to compile and run the application. Once tha the program is running , click at various points in the Form and watch the label change to report the co-ordinates of the click.
== Identifying which Mouse Button was Clicked ==
Amongst the properties of the MouseClick EventArgs object was a property named ''Button'' which may be accessed to identify which mouse button was clicked.
Exception encountered, of type "Error"
[17abafcf] /index.php/Special:MobileDiff/7043 Error from line 434 of /var/www/techotopia/includes/diff/DairikiDiff.php: Call to undefined function each()
Backtrace:
#0 /var/www/techotopia/includes/diff/DairikiDiff.php(544): DiffEngine->diag()
#1 /var/www/techotopia/includes/diff/DairikiDiff.php(344): DiffEngine->compareSeq()
#2 /var/www/techotopia/includes/diff/DairikiDiff.php(227): DiffEngine->diffLocal()
#3 /var/www/techotopia/includes/diff/DairikiDiff.php(721): DiffEngine->diff()
#4 /var/www/techotopia/includes/diff/DairikiDiff.php(859): Diff->__construct()
#5 /var/www/techotopia/includes/diff/DairikiDiff.php(980): MappedDiff->__construct()
#6 /var/www/techotopia/extensions/MobileFrontend/includes/diff/InlineDiffFormatter.php(99): WordLevelDiff->__construct()
#7 /var/www/techotopia/includes/diff/DiffFormatter.php(140): InlineDiffFormatter->changed()
#8 /var/www/techotopia/includes/diff/DiffFormatter.php(82): DiffFormatter->block()
#9 /var/www/techotopia/extensions/MobileFrontend/includes/diff/InlineDifferenceEngine.php(117): DiffFormatter->format()
#10 /var/www/techotopia/includes/diff/DifferenceEngine.php(797): InlineDifferenceEngine->generateTextDiffBody()
#11 /var/www/techotopia/includes/diff/DifferenceEngine.php(728): DifferenceEngine->generateContentDiffBody()
#12 /var/www/techotopia/extensions/MobileFrontend/includes/specials/SpecialMobileDiff.php(241): DifferenceEngine->getDiffBody()
#13 /var/www/techotopia/extensions/MobileFrontend/includes/specials/SpecialMobileDiff.php(135): SpecialMobileDiff->showDiff()
#14 /var/www/techotopia/extensions/MobileFrontend/includes/specials/MobileSpecialPage.php(53): SpecialMobileDiff->executeWhenAvailable()
#15 /var/www/techotopia/includes/specialpage/SpecialPage.php(384): MobileSpecialPage->execute()
#16 /var/www/techotopia/includes/specialpage/SpecialPageFactory.php(553): SpecialPage->run()
#17 /var/www/techotopia/includes/MediaWiki.php(281): SpecialPageFactory::executePath()
#18 /var/www/techotopia/includes/MediaWiki.php(714): MediaWiki->performRequest()
#19 /var/www/techotopia/includes/MediaWiki.php(508): MediaWiki->main()
#20 /var/www/techotopia/index.php(41): MediaWiki->run()
#21 {main}