473,623 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need some explanation with referencing controls on other forms

Hi there,

i have a test application with 2 forms - frmMain and frmDialog

the application starts with frmMain (which has a label on it called
lblStatus), and when i click a button, it opens the dialog where i can type
some text. What i cant figure out is while i'm in the dialog, i want to set
the main form's label to the text i typed in my dialog form.

any help appreciated.

when i type my referenced form "fMain" - eg. fMain. , it doesnt show me any
of the controls on the form???

thanks,
Paul
Jan 11 '07 #1
2 1141
Milsnips,

By default the class members generated for controls are private. To set the
text in the label you can:
- make its member public (or internal), which I wouldn't suggest.
- have a callback( or event) called by the dialog when the label needs to be
changed. The dialog should pass the text in a paramemter to the callback.
- have a public property on the level of the main form which when set with a
text trasnfers the text to the label.
--
HTH
Stoitcho Goutsev (100)

"Milsnips" <mi******@hotma il.comwrote in message
news:OP******** ******@TK2MSFTN GP03.phx.gbl...
Hi there,

i have a test application with 2 forms - frmMain and frmDialog

the application starts with frmMain (which has a label on it called
lblStatus), and when i click a button, it opens the dialog where i can
type some text. What i cant figure out is while i'm in the dialog, i want
to set the main form's label to the text i typed in my dialog form.

any help appreciated.

when i type my referenced form "fMain" - eg. fMain. , it doesnt show me
any of the controls on the form???

thanks,
Paul

Jan 11 '07 #2

Milsnips wrote:
Hi there,

i have a test application with 2 forms - frmMain and frmDialog

the application starts with frmMain (which has a label on it called
lblStatus), and when i click a button, it opens the dialog where i can type
some text. What i cant figure out is while i'm in the dialog, i want to set
the main form's label to the text i typed in my dialog form.

any help appreciated.

when i type my referenced form "fMain" - eg. fMain. , it doesnt show me any
of the controls on the form???
This is a common question, and it comes up because most people
(including me) do stream-of-consciousness coding: write a main form,
write a dialog, then realize that the dialog needs something from the
main form... how does it get it?

The solution becomes much easier if you think about it the other way
around: how does the main form pass the dialog what it needs? How does
the main form get information back from the dailog? (As opposed to
having the dialog push the information back to the main form on its own
initiative.)

Create a property in the dialog for the needed information. You said
that your text is a status of some kind. You could then do this:

public class MyDialog : System.Windows. Forms.Form
{
... the usual stuff ...

public string Status
{
get { return this.statusText Box.Text; }
set
{
if (value == null) throw new
ArgumentNullExc eption("value") ;
this.statusText Box.Text = value;
}
}
}

Now, in your main form, you can fetch the status from the dialog and
populate the status label:
....
using (MyDialog dlg = new MyDialog())
{
if (dlg.ShowDialog () == DialogResult.OK )
{
this.lblStatus = dlg.Status;
}
}
....

Jan 11 '07 #3

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

Similar topics

19
4086
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
2
2121
by: Susan Bricker | last post by:
Greetings. Before I begin, I have been stuck on this problem for about a 5 days, now. I have tried and just seem to be not getting anywhere. I know that the explanation is lengthy, but I am a relative newcomer to Access and need to be methodical until it become more familiar. Thanks in advance for your help. I have a form with a subform that has a subform. form: frmEvents subform: sfrmTrialInfo (controlname = )
4
1845
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain, and put them in the same-named field in the subform. Here's the function: '--------Start Code-------- Function cmdFillSub() Dim i As Integer
1
1930
by: M Shafaat | last post by:
Hi! I have made a user control called, say "MyUserCtrl", which is inherited from another user defined class called, say "MyBaseClass". Each one of these two are developed in its own project. The question: When I use MyUserCtrl in a form, I must, from the form, make reference to both classes, i.e. even to "MyBaseClass". Otherwise, it will not work. How can I manage to skip referencing MyBaseClass? I tried to put both user controls in one...
2
4066
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I want to do this as I want to use same subform on two different parent forms. Main problem is that the subform is not part of the forms collection. The only workaround I found was setting the query in code in the
2
2221
by: ccsnavy | last post by:
For some reason referencing an unbound control on an active form from a query has ceased to work correctly. While other previously existing references to unbound controls in the same form seem to work fine new ones just return null or if referencing a combo box some random character (usually a box). In fact any subsequent queries created that reference controls on active forms don't seem to work properly. What could be causing this problem? ...
4
1889
by: adam_kroger | last post by:
BRIEF EXPLANATION: I have 6 TextBoxes named LIS1, LIS2, LIS3, ... LIS6. I want to be able to reference them using a For/Next loop and either read ot write to them. In VBA I would use something like this: for i = 1 to 6 me.controls("LIS" & i).Value = "" next i Nedless to say, the Controls("LIS" & i).text doesn't work...
5
1373
kcdoell
by: kcdoell | last post by:
Good Morning: I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form: Private Sub Form_BeforeUpdate(Cancel As Integer) 'When records are added it adds the coresponding LocationsID, YearID and Month IDs 'to the new record.
2
2118
by: joancabianna | last post by:
Hello, What I am trying to do is have one form loop through its combo boxes and check to see if the value is a key word like Query_Form or Query_Form2. What I then want to happen is in either case to call another form that does on the fly calculations and then stores them in separate queries. On this new calculation form I want to have a way of saying something along the lines of If 'the other form' says Query_Form .. then call this...
0
8227
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
8670
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...
0
8613
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8326
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
8469
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
7150
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
6106
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
4074
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...
2
1473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.