在我的函数运行后如何将文本保留在 RichTextBox 中

问题描述

过去几天我一直在试图弄清楚为什么我的 RichTextBox 控件在我的程序完成后清除。我曾尝试更改 Hide SelectionMultiline 等真假设置,但没有任何效果。我什至尝试从 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 (将#修改为@)