Under RichTextBox_TextChanged event, I have
if RichTextBox.Lines.Count() > 2
{
//Message Box to display the user that you are typing more than 2 lines
}
so what i happens is when i have these data in
[0] - "East coast road"
[1]- "New York"
rich text box, when i click Enter, seems it goes into this state
[0] - "East coast road"
[1]- "New York"
[2] -""
and I get the message pop up box saying can’t have more than 2 lines, however the last line is just an empty line?
How do i handle the line restrictions in rich text box or how do i
ensure that when the user clicks enter I don’t move to the next line
and move to the next line only if there is 1 line in the rich text
box?
This returns count as 3 where in there should be only 2, how do i eliminate that white space next line?
You have kind of shotgunned the available tags. But this should give you an idea how to do it. The
KeyDownevent happens before the TextChanged event. So I would intercept the keystroke, check for the Enter Key and if the line count is 2 or greater I would Handle it. Something like this C# winforms example:To answer your question on the
HandledProperty.From Link: