RichTextBox, Mouse Cursor issues.  
Author Message
Rush hour





PostPosted: Visual C# Express Edition, RichTextBox, Mouse Cursor issues. Top

Dear all,

I have two questions and need to get some hints from u. :0)

1. Editor with the syntax functionality.

In my ongoing editor, when the user types the word, e.g. "ABC", the word "ABC" will appear in the RichTextBox with the changed color red. Afterwards, when the furhter action is taking on, e.g. user gives the input directly in the RichTextBox or types the other word, the color will be back to default one, black.

I made some basic implementations. E.g. add one richTextBox TextChanged event, and change it color afterwards. However, all the text in richTextBox will be changed, not as I wish. E.g. some specific ones will be changed, whilst the rest will be in the default color.

2. Mouse cursor.

I designed one key with the del functionality. However, everytime I use the key, the cursor always stay in the front of the text, not in the end of the text. How shall I accomplisht the task that the mouse cursor will be in the back of the text when I wanna del the text in the richTextBox.

Hopefully, I specify the issues clearly.

It is welcome to give me any feedback,

Thanks in advance,

Cordially,

Lou.



Visual Studio Express Editions3  
 
 
jimmygyuma





PostPosted: Visual C# Express Edition, RichTextBox, Mouse Cursor issues. Top

I'll take a stab at the color.

rtb.SelectionStart = 'index of A';
rtb.SelectionLength = 3;
rtb.SelectionColor = Color.Red;
rtb.SelectionStart = 'index of C + 1';
rtb.SelectionLength = 0;
rtb.SelectionColor = Color.Black;

save SelectionStart and SelectionLength before the above and restore them afterwards.

You might check out a two part article on the subject of syntax coloring at

http://www.c-sharpcorner.com/UploadFile/duncanharris/SyntaxHighlightInRichTextBoxP112012005050840AM/SyntaxHighlightInRichTextBoxP1.aspx