Click here to Skip to main content
5,787,682 members and growing! (21,751 online)
Email Password   helpLost your password?
Desktop Development » Edit Controls » General     Intermediate License: The Code Project Open License (CPOL)

Advanced Text Editor with Ruler

By Aleksei Krassovskikh

Extending RichTextBox with ruler and much more
C# (C# 2.0, C# 3.0, C#), .NET (.NET, .NET 3.5, .NET 3.0, .NET 2.0)

Posted: 8 Jan 2008
Updated: 20 Mar 2008
Views: 40,567
Bookmarked: 79 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
21 votes for this Article.
Popularity: 5.71 Rating: 4.32 out of 5
1 vote, 4.8%
1
3 votes, 14.3%
2
1 vote, 4.8%
3
1 vote, 4.8%
4
15 votes, 71.4%
5
AdvTextEdit.PNG

Introduction

About two years ago I was creating a project for university. It was a complex of five programs that were related to testing (checking knowledge I mean). One of them contained a text editor. But unfortunately, I didn't know how to do that, that's why it was very simple. So, after these two years, I decided to rewrite my program in C# .NET (initially, it was written in VB.NET) and create a new powerful text editor. You can see part of it here.

Background

I spent a lot of time(!) searching the Internet for controls like this, but the best ones are shareware and others did not fit my needs. So, what does this control have? I tried to make it look like Microsoft Word and I think that there are some similarities. The ruler lets you change the following: left and right margins, left indent, hanging indent and right indent. You also can disable margins (their values are set to 1). You can see how it looks in the picture above.

Also, you can add tabs by clicking on the control with the left mouse button. But it is allowed only inside the area bounded by margins. If you want to remove a tab, just drag it off from the control.

The editor lets you use lists, underline styles, advanced char styles (you can create your own links, that are not words starting with "http://" or even "www"), OLE functionality is also available. I want to thank Oscar Londoño for his article Inserting Images into a RichTextBox Control (The OLE Way). It helped me a lot to deal with OLE. This project contains his code.

Using the Code

You can use the code according to the CPOL.

Projects are created as Windows Applications, but you can easily convert them into *.dll or just embed code into your project.

Unfortunately, I removed Visual Studio 2005, so, sorry but I can't create and upload a Visual Studio 2005 project. But you can import all required files into a Visual Studio 2005 project without any problems. However, note that Visual Studio 2008 added some new namespaces (like LINQ) that Visual Studio 2005 does not "understand". Just remove them. That's all. You are ready.

Points of Interest

One thing that shocked me is that Microsoft has released RichTextBox 6.0! (It is distributed with Microsoft Office 2007) but... with one exception. There is no documentation about its features. All that I've found is a list of added functions. You can find it here. There are also descriptions for all released versions of RichTextBox.

History

  • 7 January 2008: Initial release
  • 16 January 2008: Projects for Visual Studio 2005 and 2008 posted instead of standalone control.
  • 26 January 2008: Posted completed AdvancedTextEditor project. It is available for Visual Studio 2005 and Visual Studio 2008.
  • 10 February 2008: Fixed PrintDialog bug. It didn't receive focus when shown. Now it's OK. Thanks to Chris Schucker for bug report and recommendations.
  • 22 February 2008: Added new functionality (full text justification, underline styles and colors and other)
  • 24 February 2008: Fixed bug with conversion from millimeter to pixel and vice versa Thanks to Chris Schucker. Also corrected bug which caused incorrect display of the indents.
  • 19 March 2008: Version 2.0 released. A lot of changes including lists, OLE, underline styles, etc.

Additions

I understand that I am not able to include everything into the control, that's why you can freely add something useful or change code to fit your needs. But, please inform me about that, just email me at krasssss@mail.ru. It's just to let anyone use an upgraded (and corrected) version of that control. Of course, advisors will be mentioned.

License

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

About the Author

Aleksei Krassovskikh


Currently I am studying at East Kazakhstan State Technical University. My future occupation is engineer-programmer.

I use Visual Basic, C#, Delphi and a little C++. Also I am interested in using SQL and Perl.
Location: Kazakstan Kazakstan

Other popular Edit Controls articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 76 (Total in Forum: 76) (Refresh)FirstPrevNext
QuestionHyperlinks in Advanced Text Editormemberfrankelman2:32 4 Jan '09  
AnswerRe: Hyperlinks in Advanced Text EditormemberAleksei Krassovskikh0:21 5 Jan '09  
QuestionSetting Ruler Margins, Indentations [modified]memberTristan Baron2:52 19 Dec '08  
GeneralUnable to set rtf property by codememberMichael Hachen3:12 10 Sep '08  
GeneralRe: Unable to set rtf property by codememberAleksei Krassovskikh6:29 10 Sep '08  
GeneralRe: Unable to set rtf property by codememberMichael Hachen2:58 11 Sep '08  
GeneralRe: Unable to set rtf property by codememberAleksei Krassovskikh4:53 12 Sep '08  
GeneralUtility of "old style formating" region ?membermoimael2:28 6 Sep '08  
GeneralRe: Utility of "old style formating" region ?memberAleksei Krassovskikh6:27 10 Sep '08  
GeneralRe: Utility of "old style formating" region ?memberminhvc17:44 21 Sep '08  
Questiontranslation to vb2005memberfrankelman12:08 28 Jul '08  
AnswerRe: translation to vb2005memberAleksei Krassovskikh21:45 16 Aug '08  
GeneralRe: translation to vb2005memberfrankelman6:01 23 Aug '08  
QuestionVisual Basic 2008 Express Editionmembermr_fj11:46 24 Jul '08  
AnswerRe: Visual Basic 2008 Express EditionmemberAleksei Krassovskikh3:21 25 Jul '08  
AnswerRe: Visual Basic 2008 Express Editionmembermr_fj15:22 26 Jul '08  
GeneralRe: Visual Basic 2008 Express EditionmemberDIMO130:19 29 Aug '08  
GeneralZoomfactormemberdiamondhh5:33 6 Jun '08  
GeneralRe: ZoomfactormemberAleksei Krassovskikh23:24 8 Jun '08  
GeneralAbout pagebreakmemberWin32nipuh21:27 28 May '08  
GeneralRe: About pagebreakmemberAleksei Krassovskikh23:34 28 May '08  
Generalgreat, what about VS2005?memberWin32nipuh2:38 22 May '08  
GeneralRe: great, what about VS2005?memberAleksei Krassovskikh9:44 22 May '08  
GeneralBugmembernazimahmed3:12 31 Mar '08  
GeneralRe: BugmemberAleksei Krassovskikh8:28 31 Mar '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Mar 2008
Editor: Deeksha Shenoy
Copyright 2008 by Aleksei Krassovskikh
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project