Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to rotate the text on the tabs of a TabControl 1

Status
Not open for further replies.

DotNetter

Programmer
May 19, 2005
194
US
I have a TabControl and have set the Alignment property to "Left" so that the buttons go down the left side of the control. What I do not like though, is that the text now reads vertically on each tab. Is there a way to still have the text on the tab of the TabControl read horizontally?

Alternatively, I suppose I could create an image and display it in the tab of the TabControl, but how can I size the image to fill the entire tab of the TabControl?

Thanks!
Dot
 
Does anyone have any "idears" on this? I didn't think it would be such a hard question... :)

Thanks very much,
Dot
 
Most posters are active during the work week, so friday night posts can often linger until monday with out a reply. I've never tries using a tab control sideways though, so I can't say.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
1. Set the Tabcontrols SizeMode to Fixed.
2. Change the TabControls ItemSize property so that it gets serialized.
3. Change the TabControls DrawMode to OwnerDrawFixed
4. Then add the following code (assuming your tabcontrol is called TabControl1)

Code:
Private Sub TabControl1_DrawItem(ByVal sender As System.Object, _
            ByVal e As DrawItemEventArgs) Handles TabControl1.DrawItem

    e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds)
    Dim sf As New StringFormat
    sf.Alignment = StringAlignment.Center
    sf.LineAlignment = StringAlignment.Center
    e.Graphics.DrawString(TabControl1.TabPages(e.Index).Text, _
            TabControl1.Font, SystemBrushes.ControlText, _
            RectangleF.op_Implicit(e.Bounds), sf)
End Sub

I found this @ and got it to work. I don't understand step 2 of the process, gets serialized.
 
Rick, thanks for the tip!

BigTimmin - wow - perfect - thanks so much! [star]!!!

Dot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top