TabControl

V

VJ

Is there any way I can get the rectangle area of the TabPage area only of a
TabControl.

I am trying here to paint my tabpage area with one color and tabPage tabs in
a different color.

Thanks
VJ
 
F

Francis Ingels [MSFT]

Sure, suppose you have a tabpage called TabPage1. The following code will
paint just the client area of the tab page red:

Dim rect As Rectangle
Dim g As System.Drawing.Graphics

rect = TabPage1.ClientRectangle()
g = TabPage1.CreateGraphics()

g.FillRectangle(System.Drawing.Brushes.Red, rect)


--------------------
 
V

VJ

That did not work.. it paints the entire area including the tab headers.. I
want just the page area to paint red...

I understand what you are saying.. I too read the help that says the client
rectangle gives the page area width, but unfournately it paints the entire
area red.. Is it because that I have also code to paint the tabs in
different color and the property DrawMode set to OwnerDrawFixed?

VJ
 
C

Cor Ligthert

Hi VJ,

I come in, do not know the problem however why than not just adjust the size
of the rectangle?

Cor
 
V

VJ

Hi Cor,

I am trying to put my math skills to full test in determining the rectangle
area.. :)...

VJ
 
Y

yEaH rIgHt

Why not set the tab page background to the desired color? Or am I missing
something here?

TabPage1.BackColor = Color.Red
 
C

Cor Ligthert

Hi VJ,

The rectangle has a rectangle.height and a rectangle.width property, I have
the same problem as you however I think that we can do that both?

:)

Cor
 
H

Herfried K. Wagner [MVP]

* "yEaH rIgHt said:
Why not set the tab page background to the desired color? Or am I missing
something here?

TabPage1.BackColor = Color.Red

This won't change the color of the tab's border and header.
 
M

Mick Doherty

A little more info on your situation is needed. The answers which others
have provided look like good answers to me. and is the reason that I have
not jumped in earlier. Perhaps you've asked the wrong question.

I take it you have an Inherited TabControl. Where and how are you doing the
painting?

you can get the tabcontrols Tabpage Rectangle by using:

Dim MyRect as Rectangle
If MyBase.TabCount > 0 Then
MyRect = Mybase.TabPages(0).Bounds
End If

Here's a link to some code for a complete Owner Draw Tab control that I
posted in the microsoft.public.dotnet.languages.vb.controls newsgroup.

Modify it to show the appearance that you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top