Good Day,
I am setting my richtextbox lines to a maximum number of 2 by determining the location of my cursor.
Code:Private line As IntegerAnd trapping my user not to enter anymore text on keypressCode:Private Sub RichTextBox1_SelectionChanged(sender As Object, e As EventArgs) Handles RichTextBox1.SelectionChanged Dim index As Integer = RichTextBox1.SelectionStart line = RichTextBox1.GetLineFromCharIndex(index) End Sub
My problem is when the user type a word or a text that is on the edge , that basically does not fit on the line, it will be moved on the nextline.Code:Private Sub RichTextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RichTextBox1.KeyPress If Char.IsLetterOrDigit(e.KeyChar) = True Then If line = 2 Then e.Handled = True End If End If If e.KeyChar = Convert.ToChar(13) Then If line = 2 Then e.Handled = True End If End If End Sub
My question is how can i prevent the user to enter a text that will cause the word to moved on the nextline, that is when the cursor is on the last line of the richtextbox.
And the wordwrap must be valued as true.
Thanks.




Reply With Quote
