473,795 Members | 3,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4379
* "scorpion53 061" <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.onteorasoft ware.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
defaultbackcolo r (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******** ******@tk2msftn gp13.phx.gbl...
* "scorpion53 061" <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.onteorasoft ware.com/VBControls.aspx #AnsTQ1>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
* "scorpion53 061" <sc************ *************** *@yahoo.com> scripsit:
this is great code but it does not address the problem of the
defaultbackcolo r (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
"scorpion53 061" <sc************ *************** *@yahoo.com> schrieb
this is great code but it does not address the problem of the
defaultbackcolo r (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.Default BackColor still calls Control.Default BackColor
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*******@free net.de> wrote in message
news:en******** *****@TK2MSFTNG P10.phx.gbl...
"scorpion53 061" <sc************ *************** *@yahoo.com> schrieb
this is great code but it does not address the problem of the
defaultbackcolo r (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.Default BackColor still calls

Control.Default BackColor 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
"scorpion53 061" <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*******@free net.de> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
"scorpion53 061" <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(Contro lStyles.AllPain tingInWmPaint Or _
ControlStyles.R esizeRedraw Or _
ControlStyles.U serPaint Or _
ControlStyles.D oubleBuffer, True)

Private m_BackColor As Color = Color.Blue
<DefaultValue(G etType(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.Equ als(Value) Then
m_BackColor = Value
Invalidate()
End If
End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
e.Graphics.Clea r(m_BackColor)
'Draw the tab items
Dim ItemBounds As Rectangle
Dim TextBrush As New SolidBrush(Colo r.Empty)
For TabIndex As Integer = 0 To Me.TabCount - 1
ItemBounds = Me.GetTabRect(T abIndex)

ControlPaint.Dr awBorder3D( _
e.Graphics, ItemBounds, _
Border3DStyle.B ump, _
Border3DSide.Al l)

Dim sf As New StringFormat
sf.LineAlignmen t = StringAlignment .Center
sf.Alignment = StringAlignment .Center

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

e.Graphics.Draw String( _
Me.TabPages(Tab Index).Text, _
Me.Font, TextBrush, _
RectangleF.op_I mplicit(Me.GetT abRect(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
5906
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. However, the "Sort Ascending" and "Sort Descending" selections provide a helpful feature. Is there a way to get that "Remove Filter/Sort" out of the Shortcut menu? I've used this in some cases, but then I lose the Sort option:
14
759
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 the screen, requiring user intervention to click "Talk" or "Hang Up". I want to customize the behavior of the application so that no pop ups are received and the application drops the line automatically and closes itself in 6 seconds - which is...
2
3802
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 directions. i tried both but for some reason i cannot delete the categories called "filter", "form", etc. eventually i would like to add commands to the "custom" category, ie commands "filter by form, "filter for:" and "filter by excluding" options and...
0
1445
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 api function. Something like DrawItem that exists for a listbox would be nice. Any ideas what function (event) do I have to override? Any general tips and hints for changing the appearance of text in a tree view control (like seen in Outlook...
2
1813
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
22980
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 happens before the document gets displayed in PrintPreviewDialog, i.e. whether entire document gets copied in printer driver spool or only 1 or 2 pages? please guide regards
5
1405
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 that to my application. Can someone please guide me how will I do this in visual c#.NET?
0
1824
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 emulate so that these hyperlinks force the postback of the appropriate linkbuttons in the pager. Let's take a pager with pager: 1 2 3 4 5 It consists of: linkbutton linkbutton label linkbutton linkbutton I want it to be: < Prev 1 2 3 4 5 Next > It...
0
1018
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 : <%@ Register TagPrefix="TAG" TagName="MyUserControl" Src="~/ascx/myUC.ascx" %> <TAG:MyUserControl runat="server"> <Header>
4
1247
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
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.