(C#.NET) Dynamically change text of a Label/Textbox at runtime

S

Soren-a

Hi all

I am working on a C#.NET CF program, and I have run into a problem.

I have two forms. One form called "Structs" and on called "DInfo".
Every 10 seconds I use a timer to call two funktions in the "Structs"
form, which create a structure called "DI_Record" containing a number
of strings.

I then use another timer on the "DInfo" form to call a funktion that
has to display data from the "DI_Record" structure on labes/textbox's
on the "DInfo" GUI. I make the call to change the text in the
labes/textbox's like this:

public void ChangeText()
{
string ChangedText = Structs.DI_Record[0].Adresse;

TextLabel.Text = ChangedText; //a public Label

textBox1.Text = ChangedText; //a public textBox

}

What happens is that the "DI_Record" is made correctly and the call
"string ChangedText = Structs.DI_Record[0].Adresse" is also succesfull
(ChangedText get the correct value). The two call's to set the text of
the label and the textBox are also succesfull (no errors).

My problem is that noting happens on the screen! The text of the label
and textBox does not change. I have tried to use
"TextLabel.Invalidate()", "TextLabel.Refresh()", "TextLabel.Update()"
after I set the text, but that does not help.

Does anyone know how to solve this problem??

Any help is much appriciated!

Regards
Søren Augustesen
 
S

Soren-a

Hi Alex.

I tried calling Application.DoEvents(), but that didn't change anything.

All suggestions are most welcome.

Regards
Søren Augustesen

Alex Feinman said:
After you change text, try calling Application.DoEvents()

--
Alex Feinman
---
Visit http://www.opennetcf.org
Soren-a said:
Hi all

I am working on a C#.NET CF program, and I have run into a problem.

I have two forms. One form called "Structs" and on called "DInfo".
Every 10 seconds I use a timer to call two funktions in the "Structs"
form, which create a structure called "DI_Record" containing a number
of strings.

I then use another timer on the "DInfo" form to call a funktion that
has to display data from the "DI_Record" structure on labes/textbox's
on the "DInfo" GUI. I make the call to change the text in the
labes/textbox's like this:

public void ChangeText()
{
string ChangedText = Structs.DI_Record[0].Adresse;

TextLabel.Text = ChangedText; //a public Label

textBox1.Text = ChangedText; //a public textBox

}

What happens is that the "DI_Record" is made correctly and the call
"string ChangedText = Structs.DI_Record[0].Adresse" is also succesfull
(ChangedText get the correct value). The two call's to set the text of
the label and the textBox are also succesfull (no errors).

My problem is that noting happens on the screen! The text of the label
and textBox does not change. I have tried to use
"TextLabel.Invalidate()", "TextLabel.Refresh()", "TextLabel.Update()"
after I set the text, but that does not help.

Does anyone know how to solve this problem??

Any help is much appriciated!

Regards
Søren Augustesen
 
Joined
Jul 21, 2006
Messages
1
Reaction score
0
I had the same problem mate a call to this.refresh did it.

and I just realized how old this post is.

Oh well google will now have the answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top