By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

Tabpages

P: n/a
Hi,

I wanted to know how i can make the title that is
displayed in a tabpage bold when it is selected.
I have 4 tabpages and i want the user to know more
clearly which one is selected.

I tried to do this but for some reason all the text on
that particular page turns bold.
Can any one give me some pointers?

Thx in advance.
btw im using VB.NET

Jul 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
You'll have to set the TabControls DrawMode property to OwnerDrawFixed and
draw the text in the TabControls DrawItem procedure.

VB.Net example:
\\\
Private Sub TabControl1_DrawItem(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DrawItemEventArgs) _
Handles TabControl1.DrawItem

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(TabControl1.TabPages(e.Index ).Text, _
New Font(e.Font, FontStyle.Bold), _
Brushes.Black, _
r, sf)
Else
e.Graphics.DrawString(TabControl1.TabPages(e.Index ).Text, _
e.Font, _
Brushes.Black, _
r, sf)
End If

End Sub
///
Note that if the Tabpage Font does not support Fonstyle.Bold then the
function will fail. In this case use:
\\\
New Font(Font.FontFamily.GenericSansSerif, _
e.Font.SizeInPoints, _
FontStyle.Bold, _
GraphicsUnit.Point)
///
in place of:
New Font(e.Font, Fonstyle.Bold)

If you have XP Visual Styles then a lot more work is required as you'll have
to PInvoke various uxtheme.dll Functions in order to draw the TabPage Header
Items.
"Alexia" <s@d> wrote in message
news:09****************************@phx.gbl...
Hi,

I wanted to know how i can make the title that is
displayed in a tabpage bold when it is selected.
I have 4 tabpages and i want the user to know more
clearly which one is selected.

I tried to do this but for some reason all the text on
that particular page turns bold.
Can any one give me some pointers?

Thx in advance.
btw im using VB.NET

Jul 21 '05 #2

P: n/a
Hi Mick

where do i write this code? Does it go in the onclick
event for each tabpage?
does the actual tabpage title not have a bold function
that will work specifically for just that text and not
everything else on that page?

thx
-----Original Message-----
You'll have to set the TabControls DrawMode property to OwnerDrawFixed anddraw the text in the TabControls DrawItem procedure.

VB.Net example:
\\\
Private Sub TabControl1_DrawItem(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DrawItemEventArgs) _ Handles TabControl1.DrawItem

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(TabControl1.TabPages (e.Index).Text, _ New Font(e.Font, FontStyle.Bold), _ Brushes.Black, _
r, sf)
Else
e.Graphics.DrawString(TabControl1.TabPages (e.Index).Text, _ e.Font, _
Brushes.Black, _
r, sf)
End If

End Sub
///
Note that if the Tabpage Font does not support Fonstyle.Bold then thefunction will fail. In this case use:
\\\
New Font(Font.FontFamily.GenericSansSerif, _
e.Font.SizeInPoints, _
FontStyle.Bold, _
GraphicsUnit.Point)
///
in place of:
New Font(e.Font, Fonstyle.Bold)

If you have XP Visual Styles then a lot more work is required as you'll haveto PInvoke various uxtheme.dll Functions in order to draw the TabPage HeaderItems.
"Alexia" <s@d> wrote in message
news:09****************************@phx.gbl...
Hi,

I wanted to know how i can make the title that is
displayed in a tabpage bold when it is selected.
I have 4 tabpages and i want the user to know more
clearly which one is selected.

I tried to do this but for some reason all the text on
that particular page turns bold.
Can any one give me some pointers?

Thx in advance.
btw im using VB.NET

.

Jul 21 '05 #3

P: n/a
Just copy and paste the code as its own procedure.
This code is written in the DrawItem event. The first line of the code gives
you a clue:
Private Sub TabControl1_DrawItem(....) Handles TabControl1.DrawItem

if it was meant to be in the click event the first line would have read:
Private Sub TabControl1_Click(....) Handles TabControl1.Click

Maybe you were confused by the Line Continuation characters I used in order
that Outlook would not autowrap the text to 76 characters and spoil the
code.

Of course this code is dependant upon your TabControl being called
TabControl1.
There is no property available to change the appearance of the Text of an
individual Tab.
The code draws all the TabPage HeaderItems of TabControl1, making only the
selected TabPages Text Bold.
"Alexia" <s@d> wrote in message
news:00****************************@phx.gbl...
Hi Mick

where do i write this code? Does it go in the onclick
event for each tabpage?
does the actual tabpage title not have a bold function
that will work specifically for just that text and not
everything else on that page?

thx
-----Original Message-----
You'll have to set the TabControls DrawMode property to

OwnerDrawFixed and
draw the text in the TabControls DrawItem procedure.

VB.Net example:
\\\
Private Sub TabControl1_DrawItem(ByVal sender As Object,

_
ByVal e As

System.Windows.Forms.DrawItemEventArgs) _
Handles TabControl1.DrawItem

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(TabControl1.TabPages

(e.Index).Text, _
New Font(e.Font,

FontStyle.Bold), _
Brushes.Black, _
r, sf)
Else
e.Graphics.DrawString(TabControl1.TabPages

(e.Index).Text, _
e.Font, _
Brushes.Black, _
r, sf)
End If

End Sub
///
Note that if the Tabpage Font does not support

Fonstyle.Bold then the
function will fail. In this case use:
\\\
New Font(Font.FontFamily.GenericSansSerif, _
e.Font.SizeInPoints, _
FontStyle.Bold, _
GraphicsUnit.Point)
///
in place of:
New Font(e.Font, Fonstyle.Bold)

If you have XP Visual Styles then a lot more work is

required as you'll have
to PInvoke various uxtheme.dll Functions in order to

draw the TabPage Header
Items.
"Alexia" <s@d> wrote in message
news:09****************************@phx.gbl...
Hi,

I wanted to know how i can make the title that is
displayed in a tabpage bold when it is selected.
I have 4 tabpages and i want the user to know more
clearly which one is selected.

I tried to do this but for some reason all the text on
that particular page turns bold.
Can any one give me some pointers?

Thx in advance.
btw im using VB.NET

.

Jul 21 '05 #4

P: n/a
Hi Mick

i pasted the code that you provided me into my form. I
have a control named TabControl1 with 4 tabpages.
The problem i am having is that the application runs with
no build error but the text that appears in the tab does
not turn bold when i click on it.
Is there anything else i need to edit in your code before
i can use it?

thx in advance
-----Original Message-----
Just copy and paste the code as its own procedure.
This code is written in the DrawItem event. The first line of the code givesyou a clue:
Private Sub TabControl1_DrawItem(....) Handles TabControl1.DrawItem
if it was meant to be in the click event the first line would have read: Private Sub TabControl1_Click(....) Handles TabControl1.Click
Maybe you were confused by the Line Continuation characters I used in orderthat Outlook would not autowrap the text to 76 characters and spoil thecode.

Of course this code is dependant upon your TabControl being calledTabControl1.
There is no property available to change the appearance of the Text of anindividual Tab.
The code draws all the TabPage HeaderItems of TabControl1, making only theselected TabPages Text Bold.
"Alexia" <s@d> wrote in message
news:00****************************@phx.gbl...
Hi Mick

where do i write this code? Does it go in the onclick
event for each tabpage?
does the actual tabpage title not have a bold function
that will work specifically for just that text and not
everything else on that page?

thx
>-----Original Message-----
>You'll have to set the TabControls DrawMode property to
OwnerDrawFixed and
>draw the text in the TabControls DrawItem procedure.
>
>VB.Net example:
>\\\
>Private Sub TabControl1_DrawItem(ByVal sender As
Object, _
> ByVal e As

System.Windows.Forms.DrawItemEventArgs) _
> Handles TabControl1.DrawItem
>
> Dim r As RectangleF = RectangleF.op_Implicit
(e.Bounds) > Dim ItemBrush As New SolidBrush (TabControl1.BackColor) > Dim sf As New StringFormat
>
> sf.Alignment = StringAlignment.Center
> sf.LineAlignment = StringAlignment.Center
>
> If CBool(e.State And DrawItemState.Selected) Then
> e.Graphics.FillRectangle(ItemBrush, e.Bounds)
> e.Graphics.DrawString(TabControl1.TabPages

(e.Index).Text, _
> New Font (e.Font, FontStyle.Bold), _
>

Brushes.Black, _ > r, sf)
> Else
> e.Graphics.DrawString(TabControl1.TabPages

(e.Index).Text, _
> e.Font, _
> Brushes.Black, _ > r, sf)
> End If
>
>End Sub
>///
>Note that if the Tabpage Font does not support

Fonstyle.Bold then the
>function will fail. In this case use:
>\\\
> New Font(Font.FontFamily.GenericSansSerif, _
> e.Font.SizeInPoints, _
> FontStyle.Bold, _
> GraphicsUnit.Point)
>///
>in place of:
> New Font(e.Font, Fonstyle.Bold)
>
>If you have XP Visual Styles then a lot more work is

required as you'll have
>to PInvoke various uxtheme.dll Functions in order to

draw the TabPage Header
>Items.
>
>
>"Alexia" <s@d> wrote in message
>news:09****************************@phx.gbl...
>> Hi,
>>
>> I wanted to know how i can make the title that is
>> displayed in a tabpage bold when it is selected.
>> I have 4 tabpages and i want the user to know more
>> clearly which one is selected.
>>
>> I tried to do this but for some reason all the text on >> that particular page turns bold.
>> Can any one give me some pointers?
>>
>> Thx in advance.
>>
>>
>> btw im using VB.NET
>>
>
>
>.
>

.

Jul 21 '05 #5

P: n/a
Hi Mick

thx for the code. it worked a treat. I just forgot to set
the Drawmode property to OwnerDrawFixed and that is whyi
couldnt get it to work.

Do u know of a way to change the background colour of the
tabpage when the relavant tab is selected?
-----Original Message-----
Hi Mick

i pasted the code that you provided me into my form. I
have a control named TabControl1 with 4 tabpages.
The problem i am having is that the application runs withno build error but the text that appears in the tab does
not turn bold when i click on it.
Is there anything else i need to edit in your code beforei can use it?

thx in advance
-----Original Message-----
Just copy and paste the code as its own procedure.
This code is written in the DrawItem event. The firstline of the code gives
you a clue:
Private Sub TabControl1_DrawItem(....) Handles

TabControl1.DrawItem

if it was meant to be in the click event the first line

would have read:
Private Sub TabControl1_Click(....) Handles

TabControl1.Click

Maybe you were confused by the Line Continuation

characters I used in order
that Outlook would not autowrap the text to 76

characters and spoil the
code.

Of course this code is dependant upon your TabControl

being called
TabControl1.
There is no property available to change the appearance

of the Text of an
individual Tab.
The code draws all the TabPage HeaderItems of

TabControl1, making only the
selected TabPages Text Bold.
"Alexia" <s@d> wrote in message
news:00****************************@phx.gbl...
Hi Mick

where do i write this code? Does it go in the onclick
event for each tabpage?
does the actual tabpage title not have a bold function
that will work specifically for just that text and not
everything else on that page?

thx

>-----Original Message-----
>You'll have to set the TabControls DrawMode propertyto OwnerDrawFixed and
>draw the text in the TabControls DrawItem procedure.
>
>VB.Net example:
>\\\
>Private Sub TabControl1_DrawItem(ByVal sender AsObject, _
> ByVal e As
System.Windows.Forms.DrawItemEventArgs) _
> Handles TabControl1.DrawItem
>
> Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds) > Dim ItemBrush As New SolidBrush(TabControl1.BackColor) > Dim sf As New StringFormat
>
> sf.Alignment = StringAlignment.Center
> sf.LineAlignment = StringAlignment.Center
>
> If CBool(e.State And DrawItemState.Selected) Then
> e.Graphics.FillRectangle(ItemBrush, e.Bounds)
> e.Graphics.DrawString(TabControl1.TabPages
(e.Index).Text, _
> New Font(e.Font, FontStyle.Bold), _
>Brushes.Black, _ > r, sf)
> Else
> e.Graphics.DrawString(TabControl1.TabPages
(e.Index).Text, _
> e.Font, _
>Brushes.Black, _ > r, sf)
> End If
>
>End Sub
>///
>Note that if the Tabpage Font does not support
Fonstyle.Bold then the
>function will fail. In this case use:
>\\\
> New Font(Font.FontFamily.GenericSansSerif, _
> e.Font.SizeInPoints, _
> FontStyle.Bold, _
> GraphicsUnit.Point)
>///
>in place of:
> New Font(e.Font, Fonstyle.Bold)
>
>If you have XP Visual Styles then a lot more work is
required as you'll have
>to PInvoke various uxtheme.dll Functions in order to
draw the TabPage Header
>Items.
>
>
>"Alexia" <s@d> wrote in message
>news:09****************************@phx.gbl...
>> Hi,
>>
>> I wanted to know how i can make the title that is
>> displayed in a tabpage bold when it is selected.
>> I have 4 tabpages and i want the user to know more
>> clearly which one is selected.
>>
>> I tried to do this but for some reason all the
texton >> that particular page turns bold.
>> Can any one give me some pointers?
>>
>> Thx in advance.
>>
>>
>> btw im using VB.NET
>>
>
>
>.
>

.

.

Jul 21 '05 #6

P: n/a
Change the color of the ItemBrush. At the moment it is declared as:
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Change that to:
Dim ItemBrush As New SolidBrush(Color.WhateverYouLike)

If you also want a custom color for the Non Selected items then add the
following two lines between Else and e.Graphics.DrawString(... :
ItemBrush.Color = Color.SomeOtherColor
e.Graphics.FillRectangle(ItemBrush, e.Bounds)

Obviously Color.WhateverYouLike and Color.SomeOtherColor wont work, but
hopefully you understand that.

"Alexia" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi Mick

thx for the code. it worked a treat. I just forgot to set
the Drawmode property to OwnerDrawFixed and that is whyi
couldnt get it to work.

Do u know of a way to change the background colour of the
tabpage when the relavant tab is selected?
-----Original Message-----
Hi Mick

i pasted the code that you provided me into my form. I
have a control named TabControl1 with 4 tabpages.
The problem i am having is that the application runs

with
no build error but the text that appears in the tab does
not turn bold when i click on it.
Is there anything else i need to edit in your code

before
i can use it?

thx in advance
-----Original Message-----
Just copy and paste the code as its own procedure.
This code is written in the DrawItem event. The first

line of the code gives
you a clue:
Private Sub TabControl1_DrawItem(....) Handles

TabControl1.DrawItem

if it was meant to be in the click event the first line

would have read:
Private Sub TabControl1_Click(....) Handles

TabControl1.Click

Maybe you were confused by the Line Continuation

characters I used in order
that Outlook would not autowrap the text to 76

characters and spoil the
code.

Of course this code is dependant upon your TabControl

being called
TabControl1.
There is no property available to change the appearance

of the Text of an
individual Tab.
The code draws all the TabPage HeaderItems of

TabControl1, making only the
selected TabPages Text Bold.
"Alexia" <s@d> wrote in message
news:00****************************@phx.gbl...
Hi Mick

where do i write this code? Does it go in the onclick
event for each tabpage?
does the actual tabpage title not have a bold function
that will work specifically for just that text and not
everything else on that page?

thx

>-----Original Message-----
>You'll have to set the TabControls DrawMode property

to
OwnerDrawFixed and
>draw the text in the TabControls DrawItem procedure.
>
>VB.Net example:
>\\\
>Private Sub TabControl1_DrawItem(ByVal sender As

Object,
_
> ByVal e As
System.Windows.Forms.DrawItemEventArgs) _
> Handles TabControl1.DrawItem
>
> Dim r As RectangleF = RectangleF.op_Implicit

(e.Bounds)
> Dim ItemBrush As New SolidBrush

(TabControl1.BackColor)
> Dim sf As New StringFormat
>
> sf.Alignment = StringAlignment.Center
> sf.LineAlignment = StringAlignment.Center
>
> If CBool(e.State And DrawItemState.Selected) Then
> e.Graphics.FillRectangle(ItemBrush, e.Bounds)
> e.Graphics.DrawString(TabControl1.TabPages
(e.Index).Text, _
> New Font

(e.Font,
FontStyle.Bold), _
>

Brushes.Black, _
> r, sf)
> Else
> e.Graphics.DrawString(TabControl1.TabPages
(e.Index).Text, _
> e.Font, _
>

Brushes.Black, _
> r, sf)
> End If
>
>End Sub
>///
>Note that if the Tabpage Font does not support
Fonstyle.Bold then the
>function will fail. In this case use:
>\\\
> New Font(Font.FontFamily.GenericSansSerif, _
> e.Font.SizeInPoints, _
> FontStyle.Bold, _
> GraphicsUnit.Point)
>///
>in place of:
> New Font(e.Font, Fonstyle.Bold)
>
>If you have XP Visual Styles then a lot more work is
required as you'll have
>to PInvoke various uxtheme.dll Functions in order to
draw the TabPage Header
>Items.
>
>
>"Alexia" <s@d> wrote in message
>news:09****************************@phx.gbl...
>> Hi,
>>
>> I wanted to know how i can make the title that is
>> displayed in a tabpage bold when it is selected.
>> I have 4 tabpages and i want the user to know more
>> clearly which one is selected.
>>
>> I tried to do this but for some reason all the

text
on
>> that particular page turns bold.
>> Can any one give me some pointers?
>>
>> Thx in advance.
>>
>>
>> btw im using VB.NET
>>
>
>
>.
>
.

.

Jul 21 '05 #7

P: n/a
PK
Hi,
I want similar functionality, but in some other button. My application
has
4 tab pages. In the final page we have review button where we do
validations
for all input. If some errors are found in particular tab page, we
want that
tab text to turn red. Errors we are finding from database or
whereever. we know
that which page has errors. But how to turn that particular tab to red
when button is clicked.

I would appreciate your response.

Thanks
PK


"Mick Doherty" <EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in message news:<e1**************@tk2msftngp13.phx.gbl>...
Change the color of the ItemBrush. At the moment it is declared as:
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Change that to:
Dim ItemBrush As New SolidBrush(Color.WhateverYouLike)

If you also want a custom color for the Non Selected items then add the
following two lines between Else and e.Graphics.DrawString(... :
ItemBrush.Color = Color.SomeOtherColor
e.Graphics.FillRectangle(ItemBrush, e.Bounds)

Obviously Color.WhateverYouLike and Color.SomeOtherColor wont work, but
hopefully you understand that.

"Alexia" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi Mick

thx for the code. it worked a treat. I just forgot to set
the Drawmode property to OwnerDrawFixed and that is whyi
couldnt get it to work.

Do u know of a way to change the background colour of the
tabpage when the relavant tab is selected?
-----Original Message-----
Hi Mick

i pasted the code that you provided me into my form. I
have a control named TabControl1 with 4 tabpages.
The problem i am having is that the application runs withno build error but the text that appears in the tab does
not turn bold when i click on it.
Is there anything else i need to edit in your code beforei can use it?

thx in advance

>-----Original Message-----
>Just copy and paste the code as its own procedure.
>This code is written in the DrawItem event. The first line of the code gives>you a clue:
> Private Sub TabControl1_DrawItem(....) Handles TabControl1.DrawItem>
>if it was meant to be in the click event the first line would have read:> Private Sub TabControl1_Click(....) Handles TabControl1.Click>
>Maybe you were confused by the Line Continuation characters I used in order>that Outlook would not autowrap the text to 76 characters and spoil the>code.
>
>Of course this code is dependant upon your TabControl being called>TabControl1.
>There is no property available to change the appearance of the Text of an>individual Tab.
>The code draws all the TabPage HeaderItems of TabControl1, making only the>selected TabPages Text Bold.
>
>
>"Alexia" <s@d> wrote in message
>news:00****************************@phx.gbl...
>> Hi Mick
>>
>> where do i write this code? Does it go in the onclick
>> event for each tabpage?
>> does the actual tabpage title not have a bold function
>> that will work specifically for just that text and not
>> everything else on that page?
>>
>> thx
>>
>> >-----Original Message-----
>> >You'll have to set the TabControls DrawMode property to
OwnerDrawFixed and>> >draw the text in the TabControls DrawItem procedure.
>> >
>> >VB.Net example:
>> >\\\
>> >Private Sub TabControl1_DrawItem(ByVal sender As Object,
_>> > ByVal e As System.Windows.Forms.DrawItemEventArgs) _>> > Handles TabControl1.DrawItem
>> >
>> > Dim r As RectangleF = RectangleF.op_Implicit (e.Bounds)>> > Dim ItemBrush As New SolidBrush (TabControl1.BackColor)>> > Dim sf As New StringFormat
>> >
>> > sf.Alignment = StringAlignment.Center
>> > sf.LineAlignment = StringAlignment.Center
>> >
>> > If CBool(e.State And DrawItemState.Selected) Then
>> > e.Graphics.FillRectangle(ItemBrush, e.Bounds)
>> > e.Graphics.DrawString(TabControl1.TabPages (e.Index).Text, _>> > New Font (e.Font,
FontStyle.Bold), _>> > Brushes.Black, _>> > r, sf)
>> > Else
>> > e.Graphics.DrawString(TabControl1.TabPages (e.Index).Text, _>> > e.Font, _
>> > Brushes.Black, _>> > r, sf)
>> > End If
>> >
>> >End Sub
>> >///
>> >Note that if the Tabpage Font does not support Fonstyle.Bold then the>> >function will fail. In this case use:
>> >\\\
>> > New Font(Font.FontFamily.GenericSansSerif, _
>> > e.Font.SizeInPoints, _
>> > FontStyle.Bold, _
>> > GraphicsUnit.Point)
>> >///
>> >in place of:
>> > New Font(e.Font, Fonstyle.Bold)
>> >
>> >If you have XP Visual Styles then a lot more work is required as you'll have>> >to PInvoke various uxtheme.dll Functions in order to draw the TabPage Header>> >Items.
>> >
>> >
>> >"Alexia" <s@d> wrote in message
>> >news:09****************************@phx.gbl...
>> >> Hi,
>> >>
>> >> I wanted to know how i can make the title that is
>> >> displayed in a tabpage bold when it is selected.
>> >> I have 4 tabpages and i want the user to know more
>> >> clearly which one is selected.
>> >>
>> >> I tried to do this but for some reason all the text
on>> >> that particular page turns bold.
>> >> Can any one give me some pointers?
>> >>
>> >> Thx in advance.
>> >>
>> >>
>> >> btw im using VB.NET
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>
.

Jul 21 '05 #8

P: n/a
Hope you can make sense of this:

\\\
Private TabPageInvalid() As Boolean.

Private Sub Form_Load(...)...
Redim TabPageInvalid(TabControl1.TabPages.Count-1)
End Sub

Private Sub ValidationButton_Click(...)...
For each tp As TabPage in TabControl1.TabPages
If tp is not validated by your checks then
TabPageInvalid(tp.TabIndex) = True
End If
Next
TabControl1.Invalidate()
End Sub

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

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

e.Graphics.FillRectangle(ItemBrush, e.Bounds)

If TabPageInvalid(e.Index) Then
e.Graphics.DrawString(TabControl1.TabPages(e.Index ).Text, _
e.Font, _
Brushes.Red, _
r, sf)
Else
e.Graphics.DrawString(TabControl1.TabPages(e.Index ).Text, _
e.Font, _
SystemBrushes.ControlText, _
r, sf)
End If

End Sub
///
"PK" <pr************@hydrochem.com> wrote in message
news:61*************************@posting.google.co m...
Hi,
I want similar functionality, but in some other button. My application
has
4 tab pages. In the final page we have review button where we do
validations
for all input. If some errors are found in particular tab page, we
want that
tab text to turn red. Errors we are finding from database or
whereever. we know
that which page has errors. But how to turn that particular tab to red
when button is clicked.

I would appreciate your response.

Thanks
PK

Jul 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.