如何解决在我的函数运行后如何将文本保留在 RichTextBox 中
过去几天我一直在试图弄清楚为什么我的 RichTextBox 控件在我的程序完成后清除。我曾尝试更改 Hide Selection
、Multiline
等真假设置,但没有任何效果。我什至尝试从 RTB 切换到普通文本框并得到相同的结果。最后,盒子里写满了文字……如果我点击表单上的任何地方,文字就会消失,这真的很烦人。
主要方法(代码段):
Private Sub Test_Activated(sender As Object,e As EventArgs) Handles MyBase.Activated
If Code = 0 And Check = 1 Then ' Check request is successful
program.Read("Velocity_value" Velocity)
If Velocity <= 12 Or Velocity > 14 Then
MsgBox(ConstString207,vbExclamation,"Velocity")
End If
Thread.Sleep(2000) ' delay 2 seconds
Me.TDisplay.Text = Me.TDisplay.Text & vbCrLf & ConstString125
Me.Invalidate()
'following steps will read the Code
program.Read("Code")
Me.TDisplay.Text = Me.TDisplay.Text & vbCrLf & ConstString8 & "" & Code
Code = 0
Me.Invalidate()
labPg1.Increment(12.5)
Application.DoEvents()
' calling safety check function to check valocity is safe to operate
SafetyCheck()
End Sub
富文本框:
Private Sub TDisplay_TextChanged(sender As Object,e As EventArgs)
'set the current caret position to the end
TDisplay.SelectionStart = TDisplay.Text.Length
'scroll it automatically
TDisplay.ScrollToCaret()
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。