Jan 24 2006

Sharping like a beer

Category: .NetRory Primrose @ 20:21

The first thing I seem to have been bitten by with my adventures into C# from my VB comfort zone is accessing control events from the form designer.

Following my VB instincts, I double click a control to get its default event in the code file, or select an event in the code file that already exists for the control. I go to the top right dropdown list to change to the event I want and.... whoa. This list doesn't display all the possible events for the control. Instead, it displays a list of all the objects, methods, properties and other definitions for the class.

So here is the situation. I have a listbox that I want to wire up dragdrop events for. Is there an easy way to do this with the designer view or the code file view? Perhaps C# people are so keyboard loving that prefer to type in the method declaration and event handler manually?

Probably I am just missing the obvious but it is hard to stop thinking like a beer.

Tags:

Comments (3) -

1.
Eddie de Bear Eddie de Bear says:

Rory,

In the designer, select the control and open up the propeties window. On the property window is a Botton that lists all the events for the selected control. Just double click on the Event you want to handle and the designer does all the rest... Easy.

2.
Geoff Appleby Geoff Appleby says:

There's a second option too.  In the forms constructor type (in my test case i had a button on the form):
button1.Click +=

Intellisense kicks in and says press tab to complete the line - you get the eventhandler line added. Then press tab again and it creates the method signature.

3.
Rory Primrose Rory Primrose says:

Sweet, thanks boys.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading