[RESOLVED] [2005] Left alignment in tabcontrol
I've seen that in order to properly display the tabpages when using alignments aside from the top one and applying the visual styles the DrawItem event is used.
I've already played a bit with it, but since I don't have too much time I was wondering if anyone out there could provide the proper code to make the tabs look like the standard ones, with the orange line when the mouse is over the tab page and all that.
Thanks in advance.
Re: [2005] Left alignment in tabcontrol
maybe you could adapt code from THIS thread
HTH
kevin
Re: [2005] Left alignment in tabcontrol
Quote:
Originally Posted by kebo
maybe you could adapt code from
THIS thread
HTH
kevin
Well, as I've said I already know how to use the DrawItem in order to customize the tabs (well, I bet that not half as well as most people here heh), but I was wondering if anyone happens to have some code to make them look like the standard XP ones.
Re: [2005] Left alignment in tabcontrol
If you use the Skybound VisualStyles component the TabControl will draw correctly without additional help.
Re: [2005] Left alignment in tabcontrol
It only takes turning on and applying the visual styles to your app by making sure you have the framework enabled in the project properties. If you are using a Sub Main module for your startup with the framework disabled then your first lines of code in the event will be to enable the VS.
Application.EnableVisualStyles
Application.DoEvents
Re: [2005] Left alignment in tabcontrol
Quote:
Originally Posted by RobDog888
It only takes turning on and applying the visual styles to your app by making sure you have the framework enabled in the project properties. If you are using a Sub Main module for your startup with the framework disabled then your first lines of code in the event will be to enable the VS.
Application.EnableVisualStyles
Application.DoEvents
Even in .NET 2.0 the TabControl does not display properly with visual styles enabled if the Alignment property is anything but Top. The Skybound VisualStyles component fixes that issue without any additional code.
Re: [2005] Left alignment in tabcontrol
Alignment - Left. I was thinking of something else but yes that is buggy.
Re: [2005] Left alignment in tabcontrol
The VisualStyles component is nice, but it's giving me some problems, mainly with a custom control:
I draw some ellipses, using CreateGraphics in the control BG, and when I place the control in a tab the graphics drawn disappear.
Any tip? or any other way of drawing those ellipses?
Re: [2005] Left alignment in tabcontrol
I have my doubts that it the VS component that's doing that. Where exactly are you doing this drawing? I'm guessing that you're doing it in the wrong place because if you were overriding the OnPaint method you would already be provided with a Graphics object so you wouldn't have to call CreateGraphics.
Re: [2005] Left alignment in tabcontrol
Sounds like you are drawing in the wrong event and so when the region gets invalidated it does not redraw your elipses etc.
For best performance you will want to only override the control that you are drawing on OnPaint event. If you are drawing on the form then it would be overridding the forms OnPaint event.
Re: [2005] Left alignment in tabcontrol
Well, I'm actually using the control Paint event, but don't use the painteventargs because of some options of the control that makes impossible to just deppend of it.
I've tried to use the graphic object on the Paint event, and it does solve the problem.
Re: [2005] Left alignment in tabcontrol
Its better to use the e.Graphics event parameter since its alreay created instead of coding in the creation of the CreateGRaphincs method.