Using multiple forms in c# windows application

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2008
Posts: 13
Reputation: kanjali is an unknown quantity at this point 
Solved Threads: 0
kanjali kanjali is offline Offline
Newbie Poster

Using multiple forms in c# windows application

 
0
  #1
May 30th, 2008
HI,

How to use multiple forms in c# windows application?
Where i need to fetch the information form "Form2" to "Form1". Here Form2 is used to get information from user and again those informations will be used in Form1.

Please suggest me to do this.

Thanks a lot,
Anjali
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Using multiple forms in c# windows application

 
0
  #2
May 30th, 2008
You mean MDI? or just you need to open Form2 from Form1 and use some values in Form1 user entered in Form2??

For second case, just create another Form let say it called Form2, some public members (TextBox, ListBox, etc...)

Add this code in Form1 to open Form2
  1. Form2 form2 = new Form2();
  2. fom2.ShowDialog();//enforces user to not back to form1 unless finishing work on form2

Get the value of form2's textbox
  1. string str = form2.textbox2.Text;
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: blovi32 is an unknown quantity at this point 
Solved Threads: 1
blovi32 blovi32 is offline Offline
Newbie Poster

Re: Using multiple forms in c# windows application

 
0
  #3
Jun 5th, 2008
Set properties in the form2, and then retrieve them when form1 becomes active again.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 13
Reputation: kanjali is an unknown quantity at this point 
Solved Threads: 0
kanjali kanjali is offline Offline
Newbie Poster

Re: Using multiple forms in c# windows application

 
0
  #4
Jun 6th, 2008
Its displaying blank values for entered textboxes in Form2.
When Form2 will disappear after entering the values, then how it will load the textbox values in Form1?
What we need to add in Form2?

Please suggest me for this.

Thanks a lot,
Anjali.....
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 13
Reputation: kanjali is an unknown quantity at this point 
Solved Threads: 0
kanjali kanjali is offline Offline
Newbie Poster

Re: Using multiple forms in c# windows application

 
0
  #5
Jun 6th, 2008
Hey its working fine now...
Thanks a lot for your suggestions.

Thanks,
Anjali .....
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 5
Reputation: chiragwebmyne is an unknown quantity at this point 
Solved Threads: 0
chiragwebmyne chiragwebmyne is offline Offline
Newbie Poster

Re: Using multiple forms in c# windows application

 
0
  #6
Jul 10th, 2008
"Set properties in the form2, and then retrieve them when form1 becomes active again"

Which proerty i have to set, can u please guide me.

Thanks
Chirag
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1
Reputation: c.v.burgess is an unknown quantity at this point 
Solved Threads: 0
c.v.burgess c.v.burgess is offline Offline
Newbie Poster

Re: Using multiple forms in c# windows application

 
0
  #7
Sep 13th, 2008
I get this:

private void button2_Click(object sender, EventArgs e)
        {
            Form3 form3 = new Form3(); form3.ShowDialog();
            string str = Form3.textBox1.Text;
        }
It tells me that "Mail.Form3.textBox1 Is inaccesable due to its pro tsction level."

PLEASE HELP!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Using multiple forms in c# windows application

 
0
  #8
Sep 14th, 2008
Because you said "Form3.textBox1.Text" you're not accessing the variable of the form you just created... you're trying to access the class direct, change "Form3.textBox1" to "form3.textBox1"
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 6
Reputation: kashifbhatti is an unknown quantity at this point 
Solved Threads: 0
kashifbhatti kashifbhatti is offline Offline
Newbie Poster

Re: Using multiple forms in c# windows application

 
0
  #9
Sep 16th, 2008
Originally Posted by c.v.burgess View Post
I get this:

private void button2_Click(object sender, EventArgs e)
        {
            Form3 form3 = new Form3(); form3.ShowDialog();
            string str = Form3.textBox1.Text;
        }
It tells me that "Mail.Form3.textBox1 Is inaccesable due to its pro tsction level."

PLEASE HELP!!!
c.v.burgess, you may need to set protection level of textbox to private or declare properties/functions to get its text. To change protection level, select the control and from properties window change the value of "Modifiers" from private to public.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC