PC Review


Reply
Thread Tools Rate Thread

Changing Label text property on another form

 
 
Mike Johnson
Guest
Posts: n/a
 
      17th May 2004
I'm new to VB.Net and programming. I just brought VB.Net Standard I'm
working on a small program for work. I've created two forms the first is
named Forms1 and the second is named SettingsForm on forms1 I've placed two
components a NotifyIcon and FileSystemWatcher. I created a event handler
called onchanged which responds to file being created in a certain
directory. Now my problem is I can't figure out how to change the label.text
property on form two (SettingsForm) from the Event Handler. Can someone
please help me? Thanks in advance.

Also is there other places that might be better suited for Newbees?


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      17th May 2004
Hi Mike,

In VB net there are 3 ways of showing a form
A MDI childform
A showdialog
A normal show from a form,

What are you using?

Cor


 
Reply With Quote
 
Simon Jefferies
Guest
Posts: n/a
 
      17th May 2004
Hello,

You should have (or store) a variable that points to form2, so in your event
"OnChanged", you'd have something like this:

Private m_SettingsForm as SettingsForm

Public Sub OnChanged()

m_SettingsForm.Show()
''' ... etc...

''' this line calls a function on the settings form to update the
label..
m_SettingsForm.UpdateLabel("Text")

End Sub

and in your settings form you'd have the following:

Public Sub UpdateLabel(ByVal LabelText As String)

''' update the label on the settings form
Label1.Text = LabelText

End Sub

HTH
Regards
Simon Jefferies
Tools Programmer, Headfirst Productions
private.php?do=newpm&u=
www.callofcthulhu.com www.deadlandsgame.com
-
"Mike Johnson" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I'm new to VB.Net and programming. I just brought VB.Net Standard I'm
> working on a small program for work. I've created two forms the first is
> named Forms1 and the second is named SettingsForm on forms1 I've placed
> two
> components a NotifyIcon and FileSystemWatcher. I created a event handler
> called onchanged which responds to file being created in a certain
> directory. Now my problem is I can't figure out how to change the
> label.text
> property on form two (SettingsForm) from the Event Handler. Can someone
> please help me? Thanks in advance.
>
> Also is there other places that might be better suited for Newbees?
>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      17th May 2004
Hi Mike,

* "Mike Johnson" <(E-Mail Removed)> scripsit:
> I'm new to VB.Net and programming. I just brought VB.Net Standard I'm
> working on a small program for work. I've created two forms the first is
> named Forms1 and the second is named SettingsForm on forms1 I've placed two
> components a NotifyIcon and FileSystemWatcher. I created a event handler
> called onchanged which responds to file being created in a certain
> directory. Now my problem is I can't figure out how to change the label.text
> property on form two (SettingsForm) from the Event Handler.


Have a look here:

<URL:http://www.google.de/groups?selm=2fvsksF31pplU1%40uni-berlin.de>

You will have to pass a reference to the form to the other form. In
your case, if you create 'Forms1' from 'SettingsForm', use the code
above. If you create 'SettingsForm' in 'Forms1', you can simply store
the reference to the created form:

\\\
Private m_My2ndForm As SettingsForm
..
..
..
m_My2ndForm = New SettingsForm()
m_My2ndForm.Show()
..
..
..
m_My2ndForm.Label1.Text = "Foo"
///

Feel free to post if you have any questions.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing BackColor Property of Main Form Label from SubForm Access User Microsoft Access Forms 10 21st Apr 2008 08:36 PM
Changing Label text property on another form, post #2 Mike Johnson Microsoft VB .NET 3 17th May 2004 05:44 PM
Changing Text property on label from dynamic imagebutton Henke Microsoft ASP .NET 1 5th May 2004 04:48 PM
Changing text box property from another form =?Utf-8?B?c2hhbA==?= Microsoft VB .NET 2 3rd Mar 2004 11:35 AM
ccsclass property for text label on web form within VS.NET 2003 FrodoBaggins Microsoft Dot NET 2 23rd Feb 2004 11:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 PM.