|
-
Mar 8th, 2010, 09:56 AM
#1
Thread Starter
Hyperactive Member
Label.text won't change.
I have written a public sub to update a label on a different form by passing in an integer. If I pass in the -1 value it will update the label, but if I pass in any other value, it will run the code (verified by stepping line by line) but the label won't update, even when adding the doevents.
Code:
Public Sub mstidlbl(ByVal cnt As Integer)
SyncLock Form_PG_Collect_Master_ID_Label
If cnt = -1 Then
Form_PG_Collect_Master_ID_Label.Label1.Text = "ID: Paused..."
Else
Form_PG_Collect_Master_ID_Label.Label1.Text = ""ID: " & cnt
End If
End SyncLock
End Sub
-
Mar 8th, 2010, 10:04 AM
#2
Re: Label.text won't change.
1. What does SyncLock Form_PG_Collect_Master_ID_Label do?
2. Why do you have two " before ID
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 8th, 2010, 10:05 AM
#3
Re: Label.text won't change.
What is the synclock about? Are you running this on a different thread?
cnt should be cnt.ToString, though that is unlikely to have any impact. I would guess that something you are doing is throwing an exception, which is being caught and consumed without showing any message. Where that could be happening is anybodies guess. Perhaps you know of some likely error handler.
My usual boring signature: Nothing
 
-
Mar 8th, 2010, 10:15 AM
#4
Thread Starter
Hyperactive Member
Re: Label.text won't change.
The extra " was just a copying error while posting. There is no error handling and yes this is working from threading... A thread is controlled from a checkbox on the main form (checked=running/start,unchecked=paused). Unchecking on the main form will launch this sub (located on a different form) and pass in -1 for the label to update with "paused". If the thread is running (it runs on a different form), it will call the sub and update what cnt is (the number of loops the thread has ran through).
changing to cnt.tostring has not made a difference. I also tried just another string without the variable and that failed to update as well (tried "hi").
-
Mar 8th, 2010, 11:12 AM
#5
Re: Label.text won't change.
My guess would be that your form is not refreshing. Try calling me.refresh to redraw the form, which will update the label. If you are in a tight loop, you may only want to do this at some interval or every 100 loops.
-
Mar 8th, 2010, 12:45 PM
#6
Re: Label.text won't change.
So a background thread is updating a control on the UI thread? That should raise a cross threading exception.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|