我使用Fileystemwatcher观看网络共享中的某个文件夹,并且不计算文本框中的行数。
我有2个richtextbox,第一个将显示行号,第二个显示更改/删除/重命名的文件。
我能够显示标签中的行总数,但也希望在richtextbox中显示行号,但问题是它将数字添加到当前,它需要在新的上添加数字线。
希望图像能够解释。
Private Sub textFolderActiviteit_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textFolderActiviteit.TextChanged
textFolderActiviteit.SelectionStart = textFolderActiviteit.Text.Length
textFolderActiviteit.SelectionLength = 0
textFolderActiviteit.ScrollToCaret()
textFolderActiviteit.Focus()
Dim currentLineIndex As Integer = textFolderActiviteit.GetLineFromCharIndex(textFolderActiviteit.SelectionStart)
Me.Label2.Text = String.Format("{0}", currentLineIndex + 1)
Me.textLineCount.Text = String.Format("{0}", currentLineIndex + 1 & vbCrLf)
End Sub
Private Sub textLineCount_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textLineCount.TextChanged
textLineCount.SelectionStart = textLineCount.Text.Length
textLineCount.SelectionLength = 0
textLineCount.ScrollToCaret()
textLineCount.Focus()
End Sub
答案 0 :(得分:0)
也许我误解了这个问题,但你不能把VbCrlf放在行号之前吗?
Me.textLineCount.Text = String.Format("{0}", vbCrLf & (currentLineIndex + 1).ToString())