473,320 Members | 2,110 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,320 software developers and data experts.

Customize Tab Control

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?

Nov 20 '05 #1
8 4365
* "scorpion53061" <sc****************************@yahoo.com> 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>
Nov 20 '05 #2
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]" <hi***************@gmx.at> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
* "scorpion53061" <sc****************************@yahoo.com> 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>

Nov 20 '05 #3
* "scorpion53061" <sc****************************@yahoo.com> 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>
Nov 20 '05 #4
"scorpion53061" <sc****************************@yahoo.com> 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

Nov 20 '05 #5
Thanks Armin.....

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

"Armin Zingler" <az*******@freenet.de> wrote in message
news:en*************@TK2MSFTNGP10.phx.gbl...
"scorpion53061" <sc****************************@yahoo.com> 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

Nov 20 '05 #6
"scorpion53061" <sc****************************@yahoo.com> 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

Nov 20 '05 #7
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" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
"scorpion53061" <sc****************************@yahoo.com> 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

Nov 20 '05 #8
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
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: deko | last post by:
I've found that the "Remove Filter/Sort" selection in the Shortcut menu (displayed on right click) produces ugly, untrappable errors, even though "Allow Filters" is set to No in the subform. ...
14
by: deko | last post by:
The below code dials a phone number when the subform datasheet cell containing the number is double clicked. The problem is that the dialer application (c:\windows\dialer.exe) pops up windows on...
2
by: JMCN | last post by:
hi i'm having a problem with the customize a shortcut menu. i read the ms office assistance: customize a shortcut menu/delete a command or add to a shortcut menu and followed the simple...
0
by: timtos | last post by:
I want to customize the appearance of node text in a treeview control. I´ve found an article about including the paint event for a treeview control but it seems that I need to catch up another win32...
2
by: Hai Ly Hoang | last post by:
Hi, Datagrid is a great control ! But now, i want to customize it : draw a picture on the header row (the topmost row) ! Is it possible ? And how ? Thanks
3
by: sachin | last post by:
How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot. Moreover, what...
5
by: msnews.microsoft.com | last post by:
Hi All, As we have seen the customize toolbar windows in almost all windows programs (Please right click on the toolbar portion in Microsoft Word and click on customize). I would like to add...
0
by: Ray | last post by:
I am trying to add a "Next >" and "<Prev" button to the pager of my datagrid. I have been able to add the hyperlinks to the pager. I am now trying to determine the correct postback script to...
0
by: Mitkip | last post by:
Does someone know how can I make a user control which allow me to customize it like a datagrid or a repeater ... For example, I would like to call my control in an aspx page like this : <%@...
4
by: Michael | last post by:
I am considering building my WebForm page using Web Parts, so that my users can customize Web application's user interface. Is there any good information on it? or step by step demo?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.