Code-Snippet-Like Functionality

vendiddy

Well-known member
Joined
May 14, 2006
Messages
64
Programming Experience
1-3
Hi, I am creating a text editor and trying to make a feature that is similiar to the code snippets feature we all have in our Visual Studio IDEs. I can do the text insertion part.

The part I'm not sure how to implement is the code snippet fields. They are the colored boxes that sort of act like editable text fields. When you press the tab key, the focus is advanced to the next field. The screenshots will probably clarify what I'm trying to achieve.

Does anyone have an idea on how I can do this?

Thanks. :)
 

Attachments

  • BeforePressingTabKey.gif
    BeforePressingTabKey.gif
    1.6 KB · Views: 38
  • AfterPressingTabKey.gif
    AfterPressingTabKey.gif
    1.6 KB · Views: 39
I would do what giadich has suggested and use a RichTextBox for this

you can use SelectedText and SelectedTextColor to actually change the specified text color, it's how the VB IDE does it for changing the VB keywords to Blue
 
Thanks, is there a way to search for already colored text in a RichTextBox? For example, if the user presses the tab key, I want the program to search for any text that is colored, suppose green, and highlight that text.


Thanks.
 
Answering my own question, I think there might be a way to do it. I found out a RichTextBox has a .RTF property is some kind of markup code. If I can figure out what RTF code corresponds to a certain coloring, I should be able to find text that is colored a specific color.

This leads me to another question: if I find the .indexOf(somecharsequence) in RichTextBox.RTF, how can I find its corresponding index in RichTextBox.Text?
 
Back
Top