473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Odd questions among 2 forms

Hi,

This has bothered me for a while.
In Form1:
private void btnToForm2_Click(object sender, System.EventArgs e)
{
Form2 MyForm2=new Form2();
MyForm2.Show();
MyForm2.textBox1.Text="open Form 2 ";
}
If I close the Form1 at this moment, the program will be closed, since the
Form1 is the starting form.

In Form2:
private void btnToForm1_Click(object sender, System.EventArgs e)
{
Form1 MyForm1=new Form1();
MyForm1.Show();
MyForm1.textBox1.Text="open Form 1 ";
this.Close();
}

My question is when I was in Form2, how can I return to the original Form1
and change the value of the Form1.textBox1 without creating another new
Form1? What have I done wrong?
Any help will be appreciated.

Jason
Nov 17 '05 #1
3 1200
Jason.

It is possible that you just are looking for the ShowDialog method, if I
look how you wrote it.

http://msdn.microsoft.com/library/de...ialogtopic.asp

I hope this helps,

Cor
Nov 17 '05 #2
Thanks Cor!
I've tried the ShowDialog method, but it's not what I want.

"Cor Ligthert [MVP]" <no************@planet.nl> ¼¶¼g©ó¶l¥ó·s»D:e$**************@TK2MSFTNGP09.phx.g bl...
Jason.

It is possible that you just are looking for the ShowDialog method, if I
look how you wrote it.

http://msdn.microsoft.com/library/de...ialogtopic.asp

I hope this helps,

Cor

Nov 17 '05 #3


"Jason Huang" wrote:
My question is when I was in Form2, how can I return to the original Form1
and change the value of the Form1.textBox1 without creating another new
Form1? What have I done wrong?
Any help will be appreciated.


Two things. First, you need to create a form2 constructor that takes a
variable of type Form1 as a paramemter, and assign it to a Form1 variable
inside Form2. Then you can do this.theForm1.foo from within Form2.

Second, you need a way to access the text in form1. You could make textBox1
public, but doing that would be a violation of good OOP design. Instead you
should create a ChangeTextbox1Text(string s) method in Form1 and make it
public. Alternately you could do the same thing using a property.
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bozo Schmozo | last post by:
Greetings! I've searched groups.google.com already to see if I can determine if using PHP/MySQL (if needed) for a web site I wish to develop. As the subject indicated, it will be a content...
3
by: Jorge | last post by:
Hi, I am new in .NET and I have some basic questions. 1 - How can I control a object from another form ? I need to change a checkbox state from another form. What's the best way to do it ? 2...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
4
by: Trevor Best | last post by:
Does anyone know of a source of some good exam (pop quiz) type questions on Access? Looking to test candidates in a job interview. Pref a mix of multiple choice and ones that have real answers. ...
0
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the...
3
by: Chris Dunaway | last post by:
I have derived a class from the System.Windows.Forms.Button class in order to draw the button differently. Among other things, I paint the background of the button in the OnPaing override. ...
1
by: TBK | last post by:
I'm trying to finish up an assignment I had for a class and basically I'm stuck. The program is supposed to take information you've entered, put it into an array, display it in a listbox and then...
1
by: robertmeyer1 | last post by:
Hi, I have 3 tables set up. tblQuestion, tblAnswer, tblClient. I have them linked together and have a sbf and mainform set up for data entry. The sbf links the questions and answers together. ...
3
by: aj | last post by:
DB2 LUW v8.2 FP 14 RHAS 2.1 Sorry if these are newbie questions. Optimizer stuff is black magic to me. For both of these, assume stats are current and an even distribution of data....
22
by: Scott M. | last post by:
I've asked this before, but not gotten any clear answers, so I'd figure I'd try again. I am an experienced ASP .NET 1.1 developer and I understand the differences between an ASP .NET 2.0 "Web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.