如果标签不可见,如何使标签可见? label.show()和label.visible = true没有给出正确的输出。 [英] How to make label visible if it is invisible? label.show() and label.visible=true is not giving the right output.
本文介绍了如果标签不可见,如何使标签可见? label.show()和label.visible = true没有给出正确的输出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Public Sub Receive()
Dim bytes(100000) As Byte
Dim bytesRec As Integer
While True ' Always receiving msg
bytes = New Byte(100000) {}
bytesRec = sender.Receive(bytes) 'bytesRec is a integer variable to store received msg number of bytes as integer
If bytesRec > 0 Then 'if any msg received then it is >0
Data = Encoding.ASCII.GetString(bytes, 0, bytesRec)
' Controls("Label" & Data).Visible = True
Controls("Label" & Data).BackColor = Color.Green
'Dim lbl As Label
'lbl = Controls("Label" & Data)
'lbl.BackColor = Color.Green
''lbl.Show()
'lbl.Visible = True
ExtractData(Data)
Me.sender.Send(Encoding.ASCII.GetBytes(Data))
End If
End While
End Sub
推荐答案
也许标签是在另一个控件下隐藏的,而且lbl.BringToFront可以做到这一点。
但是我认为这不是你的问题。
我想GUI永远不会有时间画出你的标签,因为你永远不会退出那个循环
如果你是从外部设备接收数据,那么看起来就像是COM之类的东西。
在一个额外的线程中实现Readercode(这样的循环没有问题)并在Mainthread中使用您的数据抛出事件,以便应用程序仍然响应
Maybe the Label is hidn under another control and lbl.BringToFront may do the trick.
But I think thats not your problem.
I guess the GUI never gets time to draw your label as you never exit that While-Loop
If you are receiving data from an external Device, over something like COM whitch it looks like.
Implement the Readercode in a extra Thread (there a loop like this is no problem) and Throw Events in the Mainthread with your Data so that the Application is still responsive
这篇关于如果标签不可见,如何使标签可见? label.show()和label.visible = true没有给出正确的输出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文