|
Imports System.IO
Public Class DocumentForm
Private m_DocumentPath As String = ""
Private m_CurrentStart As Integer = 0
Public Property DocumentPath() As String
Get
Return m_DocumentPath
End Get
Set(ByVal value As String)
m_DocumentPath = value
If m_DocumentPath IsNot Nothing AndAlso File.Exists(m_DocumentPath) Then
Try
rtbDocument.LoadFile(m_DocumentPath)
Catch ex As Exception
rtbDocument.LoadFile(m_DocumentPath, RichTextBoxStreamType.PlainText)
End Try
Me.Text = Path.GetFileName(m_DocumentPath)
Else
MessageBox.Show("Cannot load document: " & Environment.NewLine & Environment.NewLine _
& m_DocumentPath, "Error Loading Document")
End If
End Set
End Property
Public Sub ClearSelection()
rtbDocument.SelectedText = ""
End Sub
Public Sub FindText(ByVal argText As String)
If argText.Length = 0 Then Return
rtbDocument.Find(argText, m_CurrentStart, RichTextBoxFinds.None)
End Sub
Private Sub rtbDocument_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtbDocument.SelectionChanged
m_CurrentStart = rtbDocument.SelectionStart
If rtbDocument.SelectionLength > 0 Then
m_CurrentStart += 1 ' make sure it finds the NEXT match, not the current one
End If
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.