Connecting Tech Pros Worldwide Forums | Help | Site Map

Changing title of form dynamically.

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#1: Oct 16 '08
Is it possible to change the title of a form if a conditional statement is fulfilled?

Edit: I looked over my files and saw how to!

Expand|Select|Wrap|Line Numbers
  1. this.Text = 'new title';
  2.  
Simple *embarrassed*

OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 362
#2: Oct 16 '08

re: Changing title of form dynamically.


form.text = "bla bla bla"
joedeene's Avatar
Site Addict
 
Join Date: Jul 2008
Location: US of A
Posts: 587
#3: Oct 16 '08

re: Changing title of form dynamically.


Quote:

Originally Posted by OuTCasT

form.text = "bla bla bla"

This will not work if the form is being called from its own class, you would have to use ' this.text = "title" ' or ' me.text = "title" ' but any other class it will work that way.

joedeene
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,608
#4: Oct 17 '08

re: Changing title of form dynamically.


joedeene makes a good point. You have to have a reference to the form. Inside the form's class, "this" is a reference to the form. Outside, you would need an instance to call on.
OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 362
#5: Oct 27 '08

re: Changing title of form dynamically.


Quote:

Originally Posted by insertAlias

joedeene makes a good point. You have to have a reference to the form. Inside the form's class, "this" is a reference to the form. Outside, you would need an instance to call on.

i have used me.text = "" is most of my forms and it works.
if i wld change the title from another form it wld be the forms name .text.
joedeene's Avatar
Site Addict
 
Join Date: Jul 2008
Location: US of A
Posts: 587
#6: Oct 27 '08

re: Changing title of form dynamically.


Quote:

Originally Posted by OuTCasT

i have used me.text = "" is most of my forms and it works.
if i wld change the title from another form it wld be the forms name .text.

Yes that does work calling the me.text from anything that is on the form, but if you're changing it from a different form or class, you'll need the reference of the form, as iA has said. So, if your form's name is Form1, then anything IN the Form1 class uses "this"(c#) or "me"(VB.NET) as the reference. But calling from another class your reference is whatever you make it to be.

joedeene
Reply