1
我有這樣的自定義類標籤文本不更新一個一個的Visual Basic
Public Class labelScroll
Inherits Label
Public Shadows Property Text As String
Get
Return MyBase.Text
End Get
Set(ByVal value As String)
Dim add As String = ""
Dim result As String()
Dim i As Integer
result = Split(value, vbLf)
Dim n As Integer = 30
If (result.Length < n) Then
n = result.Length
End If
Dim start As Integer = result.Length - n
For i = start To result.Length - 1 Step 1
add += result(i) + Environment.NewLine
Next
MyBase.Text = add
End Set
End Property
End Class
我有我放在這個labelScroll上還放置一個按鈕形式:我對按鈕的單擊事件的代碼:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
LabelScroll1.Text = "1"
Threading.Thread.Sleep(1000)
LabelScroll1.Text += "2"
Threading.Thread.Sleep(1000)
LabelScroll1.Text += "3"
End Sub
當我點擊按鈕時會發生什麼,它需要2秒鐘,然後在三行上顯示「1」「2」「3」。實際上應該發生的是,當用戶單擊該按鈕時,會出現「1」,然後執行Threading.Thread.Sleep(1000)
,以便程序等待1秒鐘,然後在下一行打印「2」。
爲什麼不會發生這種情況?
非常感謝!它現在的作品:) – DemCodeLines
沒問題 - 很高興有幫助! –