Click here to Skip to main content
11,640,866 members (61,911 online)
Click here to Skip to main content

Extended RichTextBox

, 8 Nov 2008 CPOL 66.7K 10.2K 41
Rate this:
Please Sign up or sign in to vote.
Rich Text Box control with built in options
RichTextBoxExDemo

Introduction

We all drop and use Rich Text Box controls in our VB apps. It is a rich control (hence the name RichTextBox), with many options to format text. However, all options have to be used through coding in the background.

I have also worked with RTBs in several different applications, so I wrote this small extended control for the RichTextBox that displays a toolbar on top, with some common options that the user can perform. One cool option that I added is the spell check option (with help from another article on CodeProject, NetSpell - Spell Checker for .NET).

So instead of dropping the RichTextBox in your form, drop the Extended RichTextBox. Smile | :)

Background

I have seen several different posts for complete VB applications on the Internet that use RichTextBoxes to create WordPad type applications. They are very helpful for code reference, but you cannot just easily drop it in as a control and start using it. That is why I had to write this control.

Using the Code

Basically if you just need to use the control on your form, you can simply add the DLL as a reference, and be done with it. Download the demo project to see how that is setup. Make sure to include the en-US.dic file in your project. You can still use the control just as you would use a RichTextBox. The only difference is that it shows a nifty toolbox on top with options.

The actual control project is also included, so you can easily add other options and buttons if you need, or maybe even remove one if needed. All you have to do is handle the button click.

For example, this is how I handle toggling bullets:

Private Sub BulletsToolStripButton_Click(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles BulletsToolStripButton.Click
	rtb.SelectionBullet = Not rtb.SelectionBullet
	BulletsToolStripButton.Checked = rtb.SelectionBullet
End Sub

The first line performs the function, and the second line toggles the button for the function. Most function implementations are just that simple.

Points of Interest

Note that if you select text that has formatting, it actually toggles the boxes. This is handled in the SelectionChanged event of the RichTextBox by simply setting the buttons checked value by comparing what the settings are at that position in the RichTextBox.

Possible Future Updates

I might post an update with options to hide/show each button, so that it makes it easy for the control user to control it better. Also, there are tons of features to add, like ComboBox font and font size selection, picture/object insert, save/open RTF files, etc.

History

  • 8th November, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Razi Syed
Software Developer (Senior)
United States United States
My area of expertise is developing management database systems for business so that they can efficiently store and lookup existing customer's information and related data, and be able to generate various reports. My goal is to always deliver innovative design and a user friendly interface.

You may also be interested in...

Comments and Discussions

 
QuestionHow do I upload a project to this site? Pin
Member 1085265713-Nov-14 5:42
memberMember 1085265713-Nov-14 5:42 
AnswerRe: How do I upload a project to this site? Pin
Razi Syed17-Nov-14 5:10
memberRazi Syed17-Nov-14 5:10 
GeneralRe: How do I upload a project to this site? Pin
Member 1085265720-Nov-14 17:19
memberMember 1085265720-Nov-14 17:19 
Questionen-GB.dic Pin
John L Bird15-Apr-13 2:48
memberJohn L Bird15-Apr-13 2:48 
Questionchange dictionary Pin
alejandra001-Feb-13 1:21
memberalejandra001-Feb-13 1:21 
How can I change dictionary? I need to use spanish dictionary es_ES.dic and catalan dictionary ca_ES.dic

Thank you!!!
SuggestionPrinting? Pin
Member 89630883-Nov-12 10:19
memberMember 89630883-Nov-12 10:19 
QuestionURL Link Bug Pin
yatzin30-Jul-12 14:00
memberyatzin30-Jul-12 14:00 
GeneralGetting Extended RIchtext into my project Pin
Lordoasis7-Jul-12 2:59
memberLordoasis7-Jul-12 2:59 
GeneralMy vote of 5 Pin
manoj kumar choubey23-Mar-12 1:12
membermanoj kumar choubey23-Mar-12 1:12 
QuestionQuestion about saving Pin
Algeline pader21-Dec-11 3:14
memberAlgeline pader21-Dec-11 3:14 
AnswerRe: Question about saving Pin
Algeline pader21-Dec-11 3:45
memberAlgeline pader21-Dec-11 3:45 
Suggestionit's great, Pin
nasimb16-Nov-11 0:08
membernasimb16-Nov-11 0:08 
GeneralMy vote of 5 Pin
Member 334925725-May-11 11:51
memberMember 334925725-May-11 11:51 
GeneralMy vote of 5 Pin
Manfred R. Bihy22-Jan-11 7:22
memberManfred R. Bihy22-Jan-11 7:22 
QuestionHow to Load Contents and save Contents Pin
Member 315034621-Mar-10 11:18
memberMember 315034621-Mar-10 11:18 
AnswerRe: How to Load Contents and save Contents Pin
dragonrose14-Jun-10 14:13
memberdragonrose14-Jun-10 14:13 
QuestionCan one use different language dictionaries Pin
MJPreuss29-Oct-09 5:05
memberMJPreuss29-Oct-09 5:05 
QuestionHow to access the text property or equivalent Pin
RiverKid4-Dec-08 9:17
memberRiverKid4-Dec-08 9:17 
AnswerRe: How to access the text property or equivalent Pin
RiverKid4-Dec-08 10:56
memberRiverKid4-Dec-08 10:56 
GeneralRe: How to access the text property or equivalent Pin
kabowd16-Nov-09 20:59
memberkabowd16-Nov-09 20:59 
GeneralRe: How to access the text property or equivalent Pin
Member 105712894-Feb-14 8:52
memberMember 105712894-Feb-14 8:52 
GeneralRe: How to access the text property or equivalent Pin
Member 1060025516-Feb-14 22:29
memberMember 1060025516-Feb-14 22:29 
GeneralRe: How to access the text property or equivalent Pin
Member 822511426-Oct-14 9:39
memberMember 822511426-Oct-14 9:39 
GeneralRe: How to access the text property or equivalent Pin
Razi Syed12-Mar-14 4:09
memberRazi Syed12-Mar-14 4:09 
QuestionIs there support for adding pictures ? Pin
Masoud Dehghani10-Nov-08 9:03
memberMasoud Dehghani10-Nov-08 9:03 
AnswerRe: Is there support for adding pictures ? Pin
Razi Syed10-Nov-08 11:06
memberRazi Syed10-Nov-08 11:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150731.1 | Last Updated 9 Nov 2008
Article Copyright 2008 by Razi Syed
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid