473,654 Members | 3,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

big problem with forms

2 forms in project: WinForm and WinForm1

in WinForm i do:

private void button1_Click(o bject sender, System.EventArg s e)
{
WinForm1 form = new WinForm1();
form.Show();
}

in WinForm1 i try:

private void button1_Click(o bject sender, System.EventArg s e)
{
// How to
// add WinForm1.textBo x1.Text
// to WinForm.textBox 1.Text ?
}

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

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

// WinForm
private void button1_Click(o bject sender, System.EventArg s e)
{
WinForm1 form = new WinForm1(this);
form.Show();
}

// WinForm1
private WinForm creator = null;

public WinForm1(WinFor m creator)
{
this.creator = creator;
}

private void button1_Click(o bject sender, System.EventArg s e)
{
creator.textBox 1.Text = "Hello World";
this.textBox1.T ext = "Hello World";
}

This assumes WinForm.textBox 1 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****@erginso ft.com> wrote:
2 forms in project: WinForm and WinForm1

in WinForm i do:

private void button1_Click(o bject sender, System.EventArg s e)
{
WinForm1 form = new WinForm1();
form.Show();
}

in WinForm1 i try:

private void button1_Click(o bject sender, System.EventArg s e)
{
// How to
// add WinForm1.textBo x1.Text
// to WinForm.textBox 1.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
2135
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 basic geografic operations. It works fine most of the time, but sometimes it crashes with weird messages and i'm not able to track the error down - to find out the reason for this problem. It's some kind of an memory problem - I get the message...
7
3929
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 123.0000 123 i.e. I want to trim trailing zeros and (decimal point if no decimal values
1
2919
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
2415
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 treenodes defined by myself and don't understand, how to get the nodes data in the dragdrop event. I'm not very experienced in .NET and for sure there is a simple solution. I've written a short sample program, based on well known examples,
5
4136
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 NullReferenceException and InvalidOperationException : The object is currently in use elsewhere. Unfortunately this appears to be a race condition. These exceptions appear to ocurr while disposing GDI+ objects, the Graphics object seems to be the...
1
1565
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. This work fine for most cases, allowing the user to resize the form (and controls within the form. The forms them selves are create dynamically when the user drags a node from a listview to a panel (contained in a Usercontrol which is hosted by...
3
1635
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. This work fine for most cases, allowing the user to resize the form (and controls within the form. The forms them selves are create dynamically when the user drags a node from a listview to a panel (contained in a Usercontrol which is hosted by...
8
2719
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 thread to access the database and then displays a modal dialog which allows the user to cancel the task, if it is taking longer than they want, and shows them a display of how long the query has been running so far.
4
1697
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 back sometimes all outlining is shown and sometimes are not shown. I have no idea what is going wrong. What also is weird is that when I open the form from my main application I can resize the form, even though it is locked, and that when I cut...
0
2225
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 from www.franson.com For some reason my code below doesnt work - the GpsFixEvent never seems to "fire" as it were.
0
8376
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8489
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.