943,605 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 30722
  • C# RSS
May 30th, 2008
0

Using multiple forms in c# windows application

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kanjali is offline Offline
13 posts
since Mar 2008
May 30th, 2008
0

Re: Using multiple forms in c# windows application

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
c# Syntax (Toggle Plain Text)
  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
c# Syntax (Toggle Plain Text)
  1. string str = form2.textbox2.Text;
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jun 5th, 2008
0

Re: Using multiple forms in c# windows application

Set properties in the form2, and then retrieve them when form1 becomes active again.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
blovi32 is offline Offline
3 posts
since Jun 2008
Jun 6th, 2008
0

Re: Using multiple forms in c# windows application

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.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kanjali is offline Offline
13 posts
since Mar 2008
Jun 6th, 2008
0

Re: Using multiple forms in c# windows application

Hey its working fine now...
Thanks a lot for your suggestions.

Thanks,
Anjali .....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kanjali is offline Offline
13 posts
since Mar 2008
Jul 10th, 2008
0

Re: Using multiple forms in c# windows application

"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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chiragwebmyne is offline Offline
5 posts
since Nov 2007
Sep 13th, 2008
0

Re: Using multiple forms in c# windows application

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!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
c.v.burgess is offline Offline
1 posts
since Sep 2008
Sep 14th, 2008
0

Re: Using multiple forms in c# windows application

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"
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Sep 16th, 2008
0

Re: Using multiple forms in c# windows application

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kashifbhatti is offline Offline
6 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Stupid Question
Next Thread in C# Forum Timeline: XML attributes to Combobox





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


Follow us on Twitter


© 2011 DaniWeb® LLC