Home > Net >  RichTextBox do log shows keep fixed lines of how to realize?
RichTextBox do log shows keep fixed lines of how to realize?

Time:11-04

Fixed display 10 lines such as the largest log, when up to 11, are automatically deleted line 1 content, only keep the latest 10 lines log, want how to do?

CodePudding user response:

The TextChanged method processing text
Or lines array copy https://blog.csdn.net/m1430630520/article/details/99680814

CodePudding user response:

Use a listbox or listview is bad? More flexible to use,

CodePudding user response:

Do a delegated events, use a listbox or useful,

CodePudding user response:

Loved the
reference 3 floor response:
do a delegated events, use a listbox or useful,
listbox does not support text color

CodePudding user response:

It seems you still not change their own controltemplate

CodePudding user response:

reference 4 floor ltyxmfy response:
Listbox don't support text color

Listbox itself, what all don't support, but it is not what all can put inside?
You put the RichTextBox toward inside, full of 10 RichTextBox, cannot Remove the first line,

CodePudding user response:

In textchaned event handler: determine the log text newline symbol number, if more than 10, 0 ~ the first newline character data are removed.

CodePudding user response:

Public Class Form1

Dim LIMITMAXROWCOUNTS As Integer=10
Dim counts As an Integer=0
Private Sub btnAddEvent_Click (sender As Object, As EventArgs e) Handles btnAddEvent. Click

Counts +=1
DisplayLogInfo (counts)
End Sub

Private Function DisplayLogInfo (ByVal info As String) As an Integer
Dim ret As Integer=0
Dim lstArrayData As New List (Of String)
Try
With rbtLog
LstArrayData. AddRange (. Text. Split (New Char (), "& amp;" , vbLf))
LstArrayData=https://bbs.csdn.net/topics/lstArrayData.Where (Function As a String (s) Not String. IsNullOrEmpty (s)). The ToList
If lstArrayData. Count & gt; LIMITMAXROWCOUNTS Then
LstArrayData. Add (info)
LstArrayData. RemoveAt (0)
The Clear ()
For I As Integer=0 To lstArrayData. Count - 1
AppendText (String Concat (lstArrayData (I). The ToString, vbLf))
Next
The Else
AppendText (String Concat (info, vbLf))
End the If
End With
Ret=1
Catch the ex As Exception
Ret=0
End the Try
Return ret
End the Function
The End of the Class
 

CodePudding user response:

RT controls have lines properties, obtain all the collection, remove the front line, it is good to keep the back of the line, to assign a value to RT,
  • Related