Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

[VB2010] - Getting and Setting the text cursor position

$
0
0
i build these property for set\get the cursor position:
Code:

Public Property TextPos As Point
        Get
            Dim index As Integer = Me.SelectionStart
            TextPos.Y = Me.GetLineFromCharIndex(index)
            TextPos.X = index - Me.GetFirstCharIndexFromLine(TextPos.Y)
        End Get
        Set(value As Point)
            Me.SelectionStart = Me.GetFirstCharIndexFromLine(value.Y) + value.X
        End Set
    End Property

(i use 'Me', because i convert the UserControl to RichTextBox)
and heres how i use it:
Code:

Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        Dim a As Integer = InputBox("please insert the line you need")
        RichTextBox21.TextPos.Y = CInt(a)
    End Sub

why i get 1 error?
"Expression is a value and therefore cannot be the target of an assignment."
is because i use 'Y' instead a Point variable?

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>