VB.NETテキスト領域の現在の行を読み取りますか?
-
08-07-2019 - |
質問
テキスト領域と、構文の強調表示を行う機能があります。現在、RichTextBox全体を読み取ります。現在の行を含む文字列変数を取得するにはどうすればよいですか?以下は現在持っているコードです。
Private Sub HighLight()
Dim rm As System.Text.RegularExpressions.MatchCollection
Dim m As System.Text.RegularExpressions.Match
Dim x As Integer ''lets remember where the text courser was before we mess with it
For Each pass In FrmColors.lb1.Items
x = rtbMain.SelectionStart
rm = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass))
For Each m In rm
rtbMain.Select(m.Index, m.Length)
rtbMain.SelectionColor = Color.Blue
Next
rtbMain.Select(x, 0)
rtbMain.SelectionColor = Color.Black
Next
End Sub
解決
試していないが:
rtbMain.Lines(lineNumber)
Linesプロパティを配列に割り当てず、配列要素にアクセスする場合。
他のヒント
欲しいと思う
rtbMain.Lines(rtbMain.GetLineFromCharIndex(rtbMain.SelectionStart))
所属していません StackOverflow