473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Tabpages

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
8 3721
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thanos | last post by:
Hi everybody. Excuse my english is not perfect. I would to hide TabPages but I have tried >> TabPage.hide() or >> TabPage.Visible = False but no luck. Maybe the current Tab control...
4
by: Peter Row | last post by:
Hi, I have created a UserControl which is subsequently hosted on a standard form. My control has a TabControl on it but it has no TabPages configured. At runtime I create X pages and put a...
1
by: Luc | last post by:
Hi, I have a TabControl and, at runtime, I need to add some tabpages. The problem is that each tabpage is similar to the others and contains several controls. If I do...
3
by: VJ | last post by:
Is there a way to Order Tabpages.. I tried to Use a Class that implements the IComparer and a Compare method as suggested in the MSDN article. "ArrayList.Sort()" and then use the instance of...
7
by: Richard | last post by:
I have a form with seven tapages. These span only one record with a large number of fields (textboxes). On Tabpage1 I display a number of read-only text boxes. This displays information about...
8
by: Alexia | last post by:
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...
2
by: Kevin | last post by:
Although lots of people described how to workaround the lack of ability to hide and show tab pages on a tab control, I couldnt find a code example so I made one. Create a class that inherits from...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
7
by: davidpryce123 | last post by:
Dear Windows Form Designers I am developing an application that uses a TabControl with several Tabpages. On the different Tabpages I wish to allow users to have the access to the same...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.