5,545,925 members and growing! (18,075 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » Miscellaneous Controls     Intermediate

Customized Text - Orientated Controls in C# - Part I (Label Control)

By Chester Ragel

Label which can display text in any orientation and shape.
C#Windows, .NET, .NET 1.0, .NET 1.1, NT4, Win2K, WinXP, Win2003, VistaVS.NET2002, VS.NET2003, Visual Studio, Dev

Posted: 26 Sep 2004
Updated: 26 Sep 2004
Views: 64,697
Bookmarked: 47 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
31 votes for this Article.
Popularity: 6.90 Rating: 4.63 out of 5
2 votes, 6.5%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
5 votes, 16.1%
4
24 votes, 77.4%
5

Sample Image - customtext.jpg

Introduction

There are many ways in which text can be displayed. But most common ways are showing it in the path of straight line, arc, and circle. The Label which comes with NET can only display the text in the path of a straight line. This control can do that in all the main three methods, with rotation angle. Also, text can be displayed in a direction which we are interested in.

How it Works

There are a few points we must take care about, before we write:

  1. Where we must write the character.
  2. Angle of the letter with the axis.
  3. Path of the string.
  4. Direction of the string.

According to our needs, we can override the control's OnPaint method and draw the text. We must draw the text on our own using Graphics object. It has very useful methods which can be used here. TranslateTransform and RotateTransform are the common methods used to achieve this task. TranslateTransform is used to move the text, where we want it to be displayed. The other method is to rotate the character to orientate it with center.

The control has three properties, which can be used:

  • TextOrientation

    How the text must be displayed. Three methods are supported in Label. They are Rotate, Arc and Circle. We can display it in a straight line with rotation. I mean, the text will be displayed in a straight path, but the text can be rotated in any angle we want. The other is Arc, in which we can display a text in arc shape. The last one is, displaying it in circular path.

  • TextDirection

    There are two ways, which direction we want to display text when we think about displaying it in arc's path or circular one. They are clockwise and anticlockwise.

  • RotationAngle

    Text can be rotated in any angle we like. This can be mostly done in straight line.

Summary

My plan is to write custom controls in which we can rotate the text. In future, according to the feedback I get from this, I will write more custom controls where we can do text oriented works.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Chester Ragel



Occupation: Web Developer
Location: Singapore Singapore

Other popular Miscellaneous 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 26 (Total in Forum: 26) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralSimple/Perfect. Thank you!memberDouglas Berry6:28 9 Oct '08  
GeneralYes I love it.memberV# Guy2:39 23 Jun '08  
GeneralRe: Yes I love it.memberAhmad9920:22 3 Sep '08  
GeneralHow to modify this control for web forms.memberAhmad994:01 4 Jun '08  
GeneralLabelled TextboxmemberChakreee5:00 8 Sep '06  
Generalmake it support colorsmemberTheCardinal13:30 11 Aug '06  
GeneralI need rtf codes to include picturesussAnonymous9:55 10 Oct '05  
QuestionGreat Control, but...memberlgbjr22:01 20 Sep '05  
GeneralEntryPoint QuestionsussAnonymous7:39 11 Jun '05  
GeneralI need helpmemberTomek Frykas6:18 11 Jun '05  
GeneralProblems with alignementmemberdscemama3:32 13 Apr '05  
GeneralRe: Problems with alignementmemberdscemama4:13 13 Apr '05  
GeneralRe: Problems with alignementmemberlowrider19683:36 15 Dec '05  
GeneralJust what I was looking for!memberCCosgrove6:13 18 Feb '05  
GeneralOrientated TextboxmemberGreg Schroder11:12 30 Jan '05  
GeneralI need Helpmemberxkudos1:35 1 Nov '04  
GeneralRe: I need HelpmemberChester Ragel1:41 1 Nov '04  
GeneralRe: I need Helpmemberxkudos1:53 1 Nov '04  
GeneralRe: I need HelpmemberChester Ragel17:46 1 Nov '04  
GeneralRe: I need Helpmemberxkudos4:14 1 Nov '04  
GeneralRe: I need HelpmemberChester Ragel17:47 1 Nov '04  
GeneralLittle image?memberyong(zheng_yong@excite.com)6:53 27 Oct '04  
GeneralRe: Little image?memberChester Ragel18:23 27 Oct '04  
GeneralHimembermaddin12348:36 11 Oct '04  
GeneralLooks nice!memberRajesh Pillai21:33 26 Sep '04  

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

PermaLink | Privacy | Terms of Use
Last Updated: 26 Sep 2004
Editor: Smitha Vijayan
Copyright 2004 by Chester Ragel
Everything else Copyright © CodeProject, 1999-2008
Web07 | Advertise on the Code Project