Rich Text Box

msappletech

Member
Joined
May 31, 2003
Messages
9
uSING vb.net. After a single line has reached 250 characters in a rich text box control I need to automatically start a new line. The reason is that I am going to read each line back into a database table and the field length is 250 characters. So as a read through the Lines Collection of the Rich Textbox Control I want to be sure that they didnt type more then the 250 character limit.
 
I am unfamiliar with the Lines Collection of the Rich Textbox, but Im assuming (yeah, I know I shouldnt) that it returns a string in some fasion or another (or you should be able to at least cast it to a string eventually). If this is true, why cant you use the Length property to determine the length of the line?
 
Wyrd,
Thanks for you reply. What you suggest might just work. Another question. Is there an event that is fired when the RTB wraps text to a new line?

Kevin
 
I tried this code. Id does not work but I think it could with some help.

Private Sub txtEdit_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEdit.TextChanged
Dim intLineNumber As Integer
intLineNumber = txtEdit.GetLineFromCharIndex(txtEdit.SelectionStart)
MsgBox(Len(txtEdit.Lines(intLineNumber).ToString))
If Len(txtEdit.Lines(intLineNumber).ToString) = 10 Then
txtEdit.Lines(intLineNumber) = txtEdit.Lines(intLineNumber) & vbCrLf
End If


End Sub
 
Why dont you try using the KeyPress event????, count every time the user presses a key (of course if the user uses the backspace key instead of adding substract), when you reach to 250 chars break into another line
 
Back
Top