PC Review


Reply
Thread Tools Rate Thread

Customize Tab Control

 
 
scorpion53061
Guest
Posts: n/a
 
      7th Dec 2003
I am trying to build a new tabcontrol while inheriting the tabcontrol in
order to change the ,menu color of the tab control as it appears it won't
let me do it with the normal control.

With a customized control when I specify background color it won't allow it
either apparently.

Anyone know why and how I can do this?



 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      7th Dec 2003
* "scorpion53061" <(E-Mail Removed)> scripsit:
> I am trying to build a new tabcontrol while inheriting the tabcontrol in
> order to change the ,menu color of the tab control as it appears it won't
> let me do it with the normal control.
>
> With a customized control when I specify background color it won't allow it
> either apparently.


Why not base your drawing code on this code written by Ken Tucker [MVP]?

<http://www.onteorasoftware.com/VBControls.aspx#AnsTQ1>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
scorpion53061
Guest
Posts: n/a
 
      8th Dec 2003
this is great code but it does not address the problem of the
defaultbackcolor (read only) property I need to change.

Does anyone have a suggestion on how to change this? I tried "Shadows" and
it didnt work for some reason.

"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> * "scorpion53061" <(E-Mail Removed)> scripsit:
> > I am trying to build a new tabcontrol while inheriting the tabcontrol in
> > order to change the ,menu color of the tab control as it appears it

won't
> > let me do it with the normal control.
> >
> > With a customized control when I specify background color it won't allow

it
> > either apparently.

>
> Why not base your drawing code on this code written by Ken Tucker [MVP]?
>
> <http://www.onteorasoftware.com/VBControls.aspx#AnsTQ1>
>
> --
> Herfried K. Wagner [MVP]
> <http://www.mvps.org/dotnet>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Dec 2003
* "scorpion53061" <(E-Mail Removed)> scripsit:
> this is great code but it does not address the problem of the
> defaultbackcolor (read only) property I need to change.


You cannot override a shared property.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      8th Dec 2003
"scorpion53061" <(E-Mail Removed)> schrieb
> this is great code but it does not address the problem of the
> defaultbackcolor (read only) property I need to change.
>
> Does anyone have a suggestion on how to change this? I tried
> "Shadows" and it didnt work for some reason.


In addition to Herfried's reply: You cannot override it because a shared
property is tied to the type used to reference or to resolve the call. You
might Shadow the shared property in a derived class, but it would only be
called if you own code uses the type of your derived class. All the code
that refers to Control.DefaultBackColor still calls Control.DefaultBackColor
because that is the type used in the base classes - they don't know your
class.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
scorpion53061
Guest
Posts: n/a
 
      8th Dec 2003
Thanks Armin.....

Have you seen any examples showing a derived class example that would be
similar in nature?

"Armin Zingler" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "scorpion53061" <(E-Mail Removed)> schrieb
> > this is great code but it does not address the problem of the
> > defaultbackcolor (read only) property I need to change.
> >
> > Does anyone have a suggestion on how to change this? I tried
> > "Shadows" and it didnt work for some reason.

>
> In addition to Herfried's reply: You cannot override it because a shared
> property is tied to the type used to reference or to resolve the call. You
> might Shadow the shared property in a derived class, but it would only be
> called if you own code uses the type of your derived class. All the code
> that refers to Control.DefaultBackColor still calls

Control.DefaultBackColor
> because that is the type used in the base classes - they don't know your
> class.
>
>
> --
> Armin
>
> http://www.plig.net/nnq/nquote.html
> http://www.netmeister.org/news/learn2quote.html
>



 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      8th Dec 2003
"scorpion53061" <(E-Mail Removed)> schrieb
> Thanks Armin.....
>
> Have you seen any examples showing a derived class example that would
> be similar in nature?


No. (short answer but I can't add anything


--
Armin

 
Reply With Quote
 
scorpion53061
Guest
Posts: n/a
 
      8th Dec 2003
no problem.

I hate being told I "can't" do something.

But if there is no way I guess I have to accept it.

"Armin Zingler" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "scorpion53061" <(E-Mail Removed)> schrieb
> > Thanks Armin.....
> >
> > Have you seen any examples showing a derived class example that would
> > be similar in nature?

>
> No. (short answer but I can't add anything
>
>
> --
> Armin
>



 
Reply With Quote
 
Mick Doherty
Guest
Posts: n/a
 
      8th Dec 2003
There's always a way, just sometimes it is difficult to find, or a lot of
work.
In this case you need to fully take over the TabControls Drawing. Heres some
code for you to play with.

SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer, True)

Private m_BackColor As Color = Color.Blue
<DefaultValue(GetType(Color), "Blue"), _
Browsable(True)> _
Public Shadows Property BackColor() As Color
Get
Return m_BackColor
End Get
Set(ByVal Value As Color)
If Not m_BackColor.Equals(Value) Then
m_BackColor = Value
Invalidate()
End If
End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
e.Graphics.Clear(m_BackColor)
'Draw the tab items
Dim ItemBounds As Rectangle
Dim TextBrush As New SolidBrush(Color.Empty)
For TabIndex As Integer = 0 To Me.TabCount - 1
ItemBounds = Me.GetTabRect(TabIndex)

ControlPaint.DrawBorder3D( _
e.Graphics, ItemBounds, _
Border3DStyle.Bump, _
Border3DSide.All)

Dim sf As New StringFormat
sf.LineAlignment = StringAlignment.Center
sf.Alignment = StringAlignment.Center

If Me.SelectedIndex = TabIndex Then
TextBrush.Color = Color.Red
Else
TextBrush.Color = Me.ForeColor
End If

e.Graphics.DrawString( _
Me.TabPages(TabIndex).Text, _
Me.Font, TextBrush, _
RectangleF.op_Implicit(Me.GetTabRect(TabIndex)), _
sf)

Next

End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET - C# How to customize user control? =?ISO-8859-1?Q?Mika=EBl_PLOUHINEC?= Microsoft ASP .NET 3 26th Oct 2006 11:30 AM
Customize Login Control Andrew Hayes Microsoft ASP .NET 1 21st Jul 2006 11:57 AM
Customize Repeater Control =?Utf-8?B?UmFlZCBTYXdhbGhh?= Microsoft ASP .NET 0 8th Mar 2005 08:13 AM
How to customize calendar control? nick Microsoft ASP .NET 0 29th Jun 2004 09:46 PM
Customize Toolbox with Ink Control Keith Microsoft Dot NET Framework 0 25th Oct 2003 01:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:08 AM.