473,788 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change label text on another form

I'm trying to change the text in a label from another form.

lblInfo.Text = "ABC"

Works for the form your currently in but how the heck do you change that
label information from another form.

Later

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
6 9165
Use a property or pass the form with the label you want to change to the
form where you want to change it from

for example call the form used to change the label from the form with the
label:
'First give the second form a new constructor + a var to hold the form
that's passed:

Private Caller As Form1
Public Sub New(ByVal myCaller As Form)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call
Caller = DirectCast(myCa ller, Form1)
End Sub

'Then in the form with label pass the form to the second forms' constructor
dim obj as new frmUsedToChange (me)
obj.show
'in the second form to change the label
Caller.Label1.T ext = "I'm freaking changed ;-)"

hth Peter


"Roger Ries via DotNetMonster.c om" <fo***@DotNetMo nster.com> schreef in
bericht news:1a******** *************** *******@DotNetM onster.com...
I'm trying to change the text in a label from another form.

lblInfo.Text = "ABC"

Works for the form your currently in but how the heck do you change that
label information from another form.

Later

--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #2
Use a property or pass the form with the label you want to change to the
form where you want to change it from

for example call the form used to change the label from the form with the
label:
'First give the second form a new constructor + a var to hold the form
that's passed:

Private Caller As Form1
Public Sub New(ByVal myCaller As Form)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call
Caller = DirectCast(myCa ller, Form1)
End Sub

'Then in the form with label pass the form to the second forms' constructor
dim obj as new frmUsedToChange (me)
obj.show
'in the second form to change the label
Caller.Label1.T ext = "I'm freaking changed ;-)"

hth Peter


"Roger Ries via DotNetMonster.c om" <fo***@DotNetMo nster.com> schreef in
bericht news:1a******** *************** *******@DotNetM onster.com...
I'm trying to change the text in a label from another form.

lblInfo.Text = "ABC"

Works for the form your currently in but how the heck do you change that
label information from another form.

Later

--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #3
I was able to use it and it works.

But what if I wasn't opening frmUsedToChange from Form1?

Say I had opened frmUsedToChange from something else but still needed to
change a label or text box on Form1.

Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #4
I was able to use it and it works.

But what if I wasn't opening frmUsedToChange from Form1?

Say I had opened frmUsedToChange from something else but still needed to
change a label or text box on Form1.

Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #5
"Roger Ries via DotNetMonster.c om" <fo***@DotNetMo nster.com> schrieb:
But what if I wasn't opening frmUsedToChange from Form1?

Say I had opened frmUsedToChange from something else but still needed to
change a label or text box on Form1.


What you need is a reference to your instance of the form you want to
manipulate. There are different ways to make this reference available, for
example, by passing it in method parameters or assigning it to properties,
or implementing the Singleton design pattern if there can be only one
instance of a form:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainf orm&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6
"Roger Ries via DotNetMonster.c om" <fo***@DotNetMo nster.com> schrieb:
But what if I wasn't opening frmUsedToChange from Form1?

Say I had opened frmUsedToChange from something else but still needed to
change a label or text box on Form1.


What you need is a reference to your instance of the form you want to
manipulate. There are different ways to make this reference available, for
example, by passing it in method parameters or assigning it to properties,
or implementing the Singleton design pattern if there can be only one
instance of a form:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainf orm&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7

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

Similar topics

0
1831
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user to change the xml. For example, each "l_item" element appears as a row in a table labelled with a "label"; so if I have <l_item id="1"> <label>blah</label> ...
3
1630
by: Ken McCrory | last post by:
I have a web form page (.aspx) with 95 label controls that I now need to be text boxes. Is there an easy way to change those to what I want using something like a find and replace or am I stuck "changing" each one by hand by deleting the label and dragging a text box in its place? Alternatively, the reason I think I need text boxes is that I need to pass the info in the labels to another page and its not working unless I use a text box....
1
9235
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the example WebForm1.aspx and WebForm1.aspx.cs code below: WebForm1.aspx =======================================================
0
377
by: Roger Ries via DotNetMonster.com | last post by:
I'm trying to change the text in a label from another form. lblInfo.Text = "ABC" Works for the form your currently in but how the heck do you change that label information from another form. Later --
5
12689
by: Luis Ramos | last post by:
Hello, How do i change a label in another form from another one? in vb6 i use to do this: form1: private sub label1_change() form2.label1.caption="hgghjghjg" ' and the label in form2 is changed by the value i wanted end sub
4
5756
by: darnnews | last post by:
When a user selects a "Medium" in a form I have made, I would like to change a Label on the form. Can I change a label based on an update of a listbox? This code does not work: Case "Print" Me.Description = "The print article " Me.Measurement_Label = "Square Inches"
8
1931
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock Sub SetTime(ByVal intSec As Integer, ByVal intMin As Integer, ByVal intHour As Integer) Dim lblTime As New System.Web.UI.WebControls.Label lblTime.Text = "Current Time: " & intHour & ":" & intMin &
10
3595
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I had an idea: Can I simply create a list of conditions and when the doctor clicks them, they turn red? And clicking them again would make them default again? This would really make the exam better since the doctor could quickly glance at a...
2
1775
RedSunFlowers32
by: RedSunFlowers32 | last post by:
Hi - I am creating a form for my personal business site. I want people to be able to get their own shipping total for the item(s) they have purchased. I have another code from a different file I want to use. I am unclear on which lines to remove to stop the pop-up windows from asking the user to input their information. Could someone please point this out to me? Thank you! Current code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
9656
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
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10175
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
10112
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
8993
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
7518
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
6750
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.