Home All Groups Group Topic Archive Search About
Author
5 Jun 2006 10:55 PM
melton9
I have some labels that the text won't update.  I have others that do
fine.  Is there some properties I need to change or something? I've
deleted the labels and put them back in again and still nothing.  This
is driving me nuts.

Author
6 Jun 2006 2:29 AM
gene kelley
On 5 Jun 2006 15:55:27 -0700, melt***@hotmail.com wrote:

>I have some labels that the text won't update.  I have others that do
>fine.  Is there some properties I need to change or something? I've
>deleted the labels and put them back in again and still nothing.  This
>is driving me nuts.

You should really post a piece of code that shows how you are using
the problem labels.  As you mention "update", you may just need to
refresh the labels:

Label1.Text = SomeNewText
Label1.Refresh()


Gene
Author
7 Jun 2006 9:45 PM
melton9
To be honest, I just have something like label9.text = "Some Text".
This works fine normally, I've never had a problem.  But this is
differentI had the code in a module that
called mainform.label10.text, but it didn't work.  So I moved it to the
mainform code, and changed it to me. label10.text, and nothing, so I
just changed it to label10.text and still nothing even tho I have other
labels that update just fine from the mainform class and form2 class.
The only difference is that I wrote the code for the labels that work
very early in development and now its maybe a 5-6 days later and I
can't get the others to work right.  I may end up just starting from
scratch and rebuilding the form on a new project and transfering the
code over.
Author
7 Jun 2006 10:39 PM
melton9
I forgot to add that the info I put into the label is part of a
response from a webservice.  I know it works because I've tested it by
having it print out to a msgbox.  If I change the label to something
like label10.text = "Test", it still doesn't do anything.  I've tried
putting label10.refresh and nothing as well.
Author
7 Jun 2006 11:46 PM
gene kelley
On 7 Jun 2006 15:39:41 -0700, melt***@hotmail.com wrote:

>I forgot to add that the info I put into the label is part of a
>response from a webservice.  I know it works because I've tested it by
>having it print out to a msgbox.  If I change the label to something
>like label10.text = "Test", it still doesn't do anything.  I've tried
>putting label10.refresh and nothing as well.


Are you saying you have something in a routine  like:

MsgBox ("Test")
label10.text = "Test"

and MsgBox result is "Test" and Label10 result is ""?

Have you tried setting a breakpoint at one of these labels and seeing
what the label value is after executing that line of code?

I had a similiar situation once with a textbox.  The textbox initially
displayed text as expected.  I subsequently expanded the routine and
the text no longer displayed as expected.  To make a long story short,
it turned out that the value of the textbox was still initially
correct, but the updated code block had a subsequent  "misplaced" line
that was clearing the textbox.

Gene
Author
7 Jun 2006 11:58 PM
melton9
I had the msgbox setup as the result from the response, not the text.
I put the response array into a datagrid and then called column 1 on
the lookup I needed.  Like I said tho, I think I'm getting into some
unintended consequences with the imports system.threading.
Author
7 Jun 2006 11:56 PM
melton9
wow, I think I just figured a little bit of it out.  I fiddled with the
code a little and apparently I'm using threading and didn't know it.  I
have imports system.threading @ the beginning of the class but figured
I would have to initiate the threading later on for it to take effect.
So I guess I need to go deeper into the forums and look into changing
the label in a thread.

Heres what I'm getting now-------> Cross-thread operation not valid:
Control 'Label10' accessed from a thread other than the thread it was
created on.

The plan was to use threading later on once I had all the code setup.
Author
8 Jun 2006 6:57 AM
gene kelley
On 7 Jun 2006 16:56:06 -0700, melt***@hotmail.com wrote:

>wow, I think I just figured a little bit of it out.  I fiddled with the
>code a little and apparently I'm using threading and didn't know it.  I
>have imports system.threading @ the beginning of the class but figured
>I would have to initiate the threading later on for it to take effect.
>So I guess I need to go deeper into the forums and look into changing
>the label in a thread.
>
>Heres what I'm getting now-------> Cross-thread operation not valid:
>Control 'Label10' accessed from a thread other than the thread it was
>created on.
>
>The plan was to use threading later on once I had all the code setup.

Follow the exception helper to How to: Make Thread-Safe Calls to
Windows Forms Controls which has an exapmle using a textbox (which
would be same for a label).  A couple of methods are demonstrated, but
best is using the Invoke method.


Gene