943,822 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 7195
  • C# RSS
Jul 11th, 2008
0

How to use multiple forms and UserControls in c# windows application?

Expand Post »
How to use multiple forms and UserControls in c# windows application?

Where i have one toolStrip in UserControl1 (say UserControl1.cs) and onClick of ToolStripButton1
i need to open on Form1 (say Form1.cs) and Form1.cs contain only One RichTextbox control.
now i need to fetch Form1.cs richtextbox control value (text) onClick of another button of toolstripbutton2 (in Usercontrol1.cs).

Please suggest me to do this

Thanks
Chirag
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chiragwebmyne is offline Offline
5 posts
since Nov 2007
Jul 11th, 2008
0

Re: How to use multiple forms and UserControls in c# windows application?

This is how to add a new control.
C# Syntax (Toggle Plain Text)
  1. public class Form1
  2. {
  3. private UserControl1 userControl;
  4. public Form1()
  5. {
  6. InitializeComponent();
  7.  
  8. userControl = new UserControl1();
  9. this.Controls.Add(userControl);
  10. }
  11. }

Mi idea is.

1.On the UserControl1.cs create a 2 propertys one for 'toolStrimpButton1' and another for 'toolStripButton2'.

2.On the Form2.cs create a property for the RitchTextBox.

3.
On Form1.cs create a new instance of UserControl1 and add it to the form(as showed above).

Subscribe to the click event of each UserContro1's buttons(e.i ToolStripButton1.Click += new EventHnadler(ShowForm2)) and implement the handler

If you want information about 'event' see these links(both links belong to one article but these are the topics you nedd for solving your problem).
http://www.codeproject.com/KB/cs/eve...registration20

http://www.codeproject.com/KB/cs/eve...ndlingMethod23

Thanks,
Camilo
Last edited by camilojvarona; Jul 11th, 2008 at 7:23 am.
Reputation Points: 10
Solved Threads: 10
Junior Poster in Training
camilojvarona is offline Offline
89 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Need some idea
Next Thread in C# Forum Timeline: enable button on other form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC