473,387 Members | 1,569 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,387 software developers and data experts.

big problem with forms

2 forms in project: WinForm and WinForm1

in WinForm i do:

private void button1_Click(object sender, System.EventArgs e)
{
WinForm1 form = new WinForm1();
form.Show();
}

in WinForm1 i try:

private void button1_Click(object sender, System.EventArgs e)
{
// How to
// add WinForm1.textBox1.Text
// to WinForm.textBox1.Text ?
}

I tried on a miscellaneous.. but could not make it.. Can prompt as it to
make?
Nov 17 '05 #1
1 964
Hi Kostya,

WinForm1 needs a reference to WinForm to be able to create a control for it.

// WinForm
private void button1_Click(object sender, System.EventArgs e)
{
WinForm1 form = new WinForm1(this);
form.Show();
}

// WinForm1
private WinForm creator = null;

public WinForm1(WinForm creator)
{
this.creator = creator;
}

private void button1_Click(object sender, System.EventArgs e)
{
creator.textBox1.Text = "Hello World";
this.textBox1.Text = "Hello World";
}

This assumes WinForm.textBox1 is public. In general you should try to avoid changing Controls on another Form directly. Instead use properties and/or methods on WinForm that in turn changes the Controls.
On Sun, 10 Jul 2005 11:36:50 +0200, Kostya Ergin <ko****@erginsoft.com> wrote:
2 forms in project: WinForm and WinForm1

in WinForm i do:

private void button1_Click(object sender, System.EventArgs e)
{
WinForm1 form = new WinForm1();
form.Show();
}

in WinForm1 i try:

private void button1_Click(object sender, System.EventArgs e)
{
// How to
// add WinForm1.textBox1.Text
// to WinForm.textBox1.Text ?
}

I tried on a miscellaneous.. but could not make it. Can prompt as it to
make?


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2

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

Similar topics

2
by: Christian Kreimer | last post by:
Hi I created an C# windows forms application that holds a user control. The user control itself is an editor for geographical information systems and is based on an ActiveX Library for providing...
7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
0
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop...
5
by: anonymous | last post by:
I'm writing a program that deals extensively with the printer. For the most part my application runs fine, but occasionally I run into some Exceptions. The most common exceptions I run into are...
1
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. ...
3
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. ...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
0
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.