How can I change the border color and size of a TabControl?
How 开发者_开发百科can I change the border size/style/color of my TabControl
to make it blend in with my form's background color?
I am unable to find any property for this in Visual Studio. Is this possible?
The TabControl
isn't expecting to be placed over a custom-colored background. What you're seeing at the edges is the standard color used for 3D controls. You normally wouldn't notice that if you hadn't changed the background color of your form. By default, they're the same color.
I don't know of any good way to fix this. The TabControl
doesn't expose an awful lot of built-in options for customizing its appearance. You're going to have to owner draw and paint it a custom color yourself.
Visit this page for some different options and sample code. I suspect that the Completely OwnerDraw TabControl is what you need; use the code that's provided and customize it to your liking. Be thankful someone else has already done all the work for you, because implementing this yourself is non-trivial.
Also note that changing the DrawMode
to "OwnerDrawFixed" will disable themes. Your control will look like it came straight out of Windows 95, instead of getting drawn in the Luna or Aero theme styles. Not a big deal if you're completely customizing how it's painted, but a pain in the rear if all you want is to change the background color.
if you are trying to hide the borders and blend them with the form's backcolor, put the TabControl in a container like "Panel" control and make the size of the TabConrol bigger than the Panel control size, but this will cover the Tabs Buttons also, and for this issue you can add button for each tab and set the button's click event to to change the TabControl's SelectedTab property. Note: you can keep the TabControl in a location where you can change the tab in designtime then add the small following code on form's Load event to hide the Tabs buttons on runtime:
Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
TabControl.ItemSize = New Size(0, 1)
TabControl.SizeMode = TabSizeMode.Fixed
End Sub
Me.TabPage1.BackColor = Color.Blue
Try this, it will be helpful to you.
精彩评论