hi! I'm messing with the new Visual Studio 2005, and I'm totally loving it, but there is something that is driving me nuts. In 2003, if I was working on a form, and double clicked a control it would create a handler and shoot me to the code view. I loved that, and obviously 2005 still does it.

However, in 2003 I could also select controls from the dropdown list on the left in the code view, then select the event from the drop down list on the right and VS would again create an event handler and all associations necessary. In other words I would point, click, and fill in the appropriate code.

But now, in 2005, I can only get this done by double clicking and getting the default handler (usually load or clicked), but if I want to code other handlers, I have to go into the other cs file and add a new handler manually. I'm certain there is an easy way to get the previous way of doing things, but I can't figure out how.

Do you know what I mean? what I'm looking for? If you do and you know how, please help me!

thank you! :)
-SelArom

Recommended Answers

All 4 Replies

aha so it seems maybe it's not a factor of partial classes but rather C#? I didn't realize the languages were different this way... or are they? I can't find any information on how to do this in C# so I guess so... I've only just barely started dabbling in C# after using VB.NET for about a year so this comes as a big shock :)

is the only way to write handlers in C# actually coding a function then adding it manually as an event handler?

-SelArom

heh never mind, I just figured it out! when I add the event handler to the event I can have it automatically generated by hitting TAB after typing the +=

but is there any way to make it generate the handler in the other file (since it's a partial class I want all the events that will be changed in a seperate file, that's a good idea right?)

ahh it's late I must really sound crazy... I'm going to bed good night!

-SelArom

I am slightly lost but i think i know what you mean.
In design view in all VS (2002, 2003 and 2005) you can click the events icon in the properties box (normally you have it in properties view to fill in the name, text, color etc.).
Switching to events view shows all the events available (key-press, mouseover, click, doubleclick etc). By double clicking the event name you want, VS will automatically put the code block in (as it did with the default code block for the control but this time the event you chose).
The will put that code block in the file it defaults to (normally your default .cs file partial class in 2005). If you have created a partial class yourself (say JUST for event handling - and on larger objects it is a good idea) then unfortunately VS does not know where you want things so have to manually add the event handler in code typing in

object.eventname += new Eventnamehandler (event signature)

When you type the += VS will automatically ask you in intellisense if you want to add the default handler signature stuff.

I am slightly lost but i think i know what you mean.
In design view in all VS (2002, 2003 and 2005) you can click the events icon in the properties box (normally you have it in properties view to fill in the name, text, color etc.).
Switching to events view shows all the events available (key-press, mouseover, click, doubleclick etc). By double clicking the event name you want, VS will automatically put the code block in (as it did with the default code block for the control but this time the event you chose).
The will put that code block in the file it defaults to (normally your default .cs file partial class in 2005). If you have created a partial class yourself (say JUST for event handling - and on larger objects it is a good idea) then unfortunately VS does not know where you want things so have to manually add the event handler in code typing in

object.eventname += new Eventnamehandler (event signature)

When you type the += VS will automatically ask you in intellisense if you want to add the default handler signature stuff.

yeah that little icon was exactly what I needed. I guess us VB programmers are just spoiled :D

thank you for your help!

-SelArom

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.