Link to home
Start Free TrialLog in
Avatar of allday
allday

asked on

new to c# help required :)

my background is from vb and kinda confuse me a lot when it comes to even.handels

my questions is: in vb.net when you double click any control the vb.net creates for you the event handler for an example

if i double click on the ddl and i will get:

 Private Sub ddl_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddl.SelectedIndexChanged
   
but in c# it does not create handles and how should create those handles? what is the best way and after is spent 1 hour i figured out that there is place called >>>private void InitializeComponent()<<< where it initialize all the handles but what if if i don't know the correct handles ?

thanks
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi There,

I guess... even C# creates stub automatically which version of VS 2003 you are using?

Regards,
Chinmay
Hi There,

ooops! I mean which version of Visual Studio you are using?

Regards,
Chinmay
Avatar of allday
allday

ASKER

i'm using vs 2003
Did not my comment at the top answer you question?
Ya, Fernando is on the ball with this one.  The auto-wireup functionality is internal to the IDE and there's no kind of configuration setting that could
accidentally get flubbed up (that's not to say that the mechanisms responsible for carrying out the auto-wireup can't get flubbed up).
The question is, was this a one time occurance or is this (to use Microsofts terminology) "anomaly" reproduceable?

For some last resort troubleshooting points-of-reference:
a) When you double click a control in the Forms Designer, does it automatically switch you to Code View?
        a.1) If it does switch you to Code View, where is the cursor coming to rest? It may be the case that the
               event handler is being defined, but it doesn't automatically take you directly to the handler definition.
        a.2) If if does NOT switch to Code View, does it do anything? Is there any kind of indication as to the current status in
               the Output window or any other indication as to the programs status?
b) Is it only a DDL control that you're having issues with, or any control you double click?
        b.1) If it's only certain control(s), you could try removing the suspect control from the toolbox, and then
               adding it again.
               To remove a control, right click the control in the toolbox, select "Add/Remove Item", navigate to the corresponding
               checkbox for the control and uncheck it. The reverse is true to add the control back in.
        b.2) While in the process of doing b.1, you could also take note of the associated Assembly, which is listed in the third
               column of the Add/Remove dialog box that comes up, and do some investigating through the .NET assembly configuration
               utility in your Administrator Tools folder. It's actually just an MMC snap-in that you can access from a run prompt if that's
               your preference.
c) Are the rest of the required statements being added? Namely, the Form classes instance variable for the control (private System.Windows.Forms.DDL ddl_name),
    the object instantiation statement (this.ddl_name = new System.Windows.Forms.DropDownList()),
    the wireup statement (this.ddl_name += new System.EventHandler(this.ddl_nameEvent)).
        c.1) If all three aren't present or are somehow incorrect, it could be causing problems.
        c.2) After you double-click the control and no event handler is defined, does the solution still build with no errors? If there are errors, are any related to the DDL control?

Again, those are just some general things to look at which may possibly shed some light on extenuating circumstances that are contributing to your problem.
One last point also in reference to your comment, ">>>private void InitializeComponent()<<< where it initialize all the handles but what if if i don't know the correct handles ?"
The auto-event wire up is just a nicety that VS does to save undo heartache on the developer. Worst case scenario for you is you'll have to just manually (gasp!) create your own
event handler, which could be a benefit for you to do anyway in that it would give you an understanding of the event-driven model of Windows Forms.
A good article to read if you're so inclined is:
http://www.csharphelp.com/archives/archive253.html

Most likely, your problem has already been resolved, but the troubleshooting points above are applicable to a lot of problems that can arise through your development
process.
Better luck in the future,

Vice