Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I've been primarily a VB developer, but now doing a project in C#. In VB, whether you're doing a Windows or a web app, the left-hand dropdown of every code-behind page shows the name of the form/page and all the controls on that page. You can select any item, and them in the right-hand dropdown, it'll show you all the available events for that control; select a pair, and it automatically adds the template for that code block for you if it's not already defined, or navigates to it if it's there already. I've seen that there is a way of adding such a code block for control events (selecting through the properties window), but there appears to be no way to do it for form-level events. Am I missing something? Is there any purpose at all to the left-hand dropdown in C#? Any purpose other than (ham-handed) navigation for the right-hand dropdown?

EDIT: Must be C#-only developers responding, because this doesn't bother anyone. I asked around the office and no one knew either. Some said it may be a bug, but hard to believe MS would have left if there as long as I've been aware of it (I'm not totally new to C#, just never did anything big or from scratch). Yes, as I said above, I see that you can do control events and Windows form events using the Properties window. But why not page events? And again ... what is the purpose of that left dropdown? This likely only bothers someone who's used VB, where those dropdowns are functional and helpful shortcuts.
Posted
Updated 2-Aug-13 9:11am
v2
Comments
[no name] 2-Aug-13 14:33pm    
"form-level events. Am I missing something?", yes you are missing something. With the form showing in the designer, you can access the form level events by clicking the "lightning bolt" in the properties window.
Manish (Mack) 2-Aug-13 14:37pm    
They are just a simple way of navigation depending on the Development Environment of the software product
woopsydoozy 2-Aug-13 15:13pm    
Thanks--the navigation may indeed be the only purpose of the right-hand dropdown. The left? Maybe just for cases when multiple classes are in a single file? (Anyone doing that a lot?)
Sergey Alexandrovich Kryukov 2-Aug-13 14:44pm    
I cannot even understand the concern. The access to the form events are right before your eyes. By the way, I recommend not adding any events by the designer and not overusing the designer in general, but many still want to add events using the designer and do it. (The problem is just the opposite: you accidentally double-click somewhere on the form and it creates the event you did not need. :-)
—SA

1 solution

Please see my comment to the question: it's hard to see what you are missing. If you really need to add any event handler using the designer, you first select the control you need. It absolutely does not matter if this control is the form or some child control. There is no special "form level". Then you need to activate the "Properties" window which shows all the accessible members of your control, including all of the events you can handle. You click on the appropriate event on the property grid and obtain the code block already added to the invocation list of the chosen event instance, so this block will be called as the handler of this event. Than you just add the code for this handler.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900