Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Developers:

I am new in programming C#, i have a question about handling Usercontrol in win forms. i have started new project, in it i added a menu strip.

Menu have following List of Item:

New Member
Modify Member
Delete Member


i have add three usercontrol for each of menu items and named them:

NewMember_UserControl
ModifyMember_UserControl
DeleteMember_UserControl


Now what i want to do is: when i click on the New Member Menu Item, Usercontrol "NewMember_UserControl" display on the Main form's area below the menustrip.

Please help me in writing menu even handler for UserControl.
Posted

Try:
C#
NewMember_UserControl nmuc = new NewMember_UserControl();
Controls.Add(nmuc);


Strictly speaking, it'll do what you asked for, but I can't help thinking that what you actually want to do is something quite different altogether...
 
Share this answer
 
Comments
Hammad Rasheed 26-Oct-11 6:27am    
thanks brother it works for me... now can you tell me please... if i add a panel into client area. how can we display usercontrol into that panel...?
OriginalGriff 26-Oct-11 6:30am    
Change
Controls.Add(nmuc);
to
MyPanel.Controls.Add(nmuc);
Hammad Rasheed 26-Oct-11 6:37am    
Thanks alot ... appriciated...
Further to Griff's excellent answer, you may find it better to have a single MemberControl that supports three modes [new, amend and delete] that changes which fields are enabled and the action resulting from the form.
It is a good design approach to show the same control for the same thing. In your case you want a control that displays a member, that is unchanged irrespective of the mode, that will have slightly different behaviour behind the scene.
 
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