Label problem

  • Thread starter Thread starter melton9
  • Start date Start date
M

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.
 
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
 
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.
 
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.
 
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
 
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.
 
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.
 
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
 
Back
Top