Sascha B

Sascha B

  • NA
  • 237
  • 0

How to style the Tabs from TabControl?

Nov 30 2010 8:07 AM
Hi,

I have a save system and want to show the user that something isn't saved yet.
Is there a way to change the style from the tabs individually?
I don't mean the complete TabPage only the little button, the selecter.
Can I add an icon or something like this?

Answers (10)

1
Jean Paul

Jean Paul

  • 26
  • 43k
  • 9.4m
Nov 30 2010 10:56 AM

Attachment: ccTabControl.zip

Dude.. Probably you are right.

To make sure we both are on the same page.. Please check the attached file.

Unzip it, and include it in the windows application.  Drag the custom control from Toolbox and run it.

Mark as answer if it solves, else let me know.
Accepted Answer
2
Sam Hobbs

Sam Hobbs

  • 54
  • 29.3k
  • 2.1m
Dec 1 2010 4:37 AM
I am more familiar with tab controls at the Windows API level and I hope that is enough for me to help here.


I don't know what a ccTabPage is; I will assume you mean TabPage. I also assume that you already have TabPages for your tab control. So I think you just have to modify the TabPage.Text property and either include an asterisk or don't include it based on whether the data is changed. Does that sound good?
0
Jean Paul

Jean Paul

  • 26
  • 43k
  • 9.4m
Dec 2 2010 2:59 AM
Good to hear that Crish :)
0
Crish

Crish

  • 0
  • 2.4k
  • 91.8k
Dec 2 2010 2:16 AM
Hi

I think its very useful in my project.Thank you for giving me solution about style the Tabs from Tab Control.Its little complicate but I know how to customize it.
0
Jean Paul

Jean Paul

  • 26
  • 43k
  • 9.4m
Dec 1 2010 10:29 AM
Thanks Sascha.. and all of you for inputting some ideas
0
Sascha B

Sascha B

  • 0
  • 237
  • 0
Dec 1 2010 4:43 AM
Yeah I think I shouldn't make it so difficult.
I just add symbols to the TabPage Header's string and that's it.
I'm just a customize guy and I wanted to make it looks really cool
so I tried to solve this with an image.
But now. Functionality goes first!
Thanks to both of you.
Jean Paul: Thanks for teaching me how to customize standart controls
and Sam Hobbs: to bring me back to the ground and bring me back thinking simply.
0
Sascha B

Sascha B

  • 0
  • 237
  • 0
Dec 1 2010 2:53 AM
Thanks Jean Paul now I know how to customize it.
But Sam Hobbs said asterris. And that is exact what I wanna to do.

I think that I have to create a ccTabPage like the ccTabControl with an attribute to
control if the
asterris is visible or not. Am I right?
0
Sam Hobbs

Sam Hobbs

  • 54
  • 29.3k
  • 2.1m
Nov 30 2010 8:23 PM
Microsoft just uses an asterrisk in the title of documents that have been modified and not saved, so if you were to do that, then most people would easily understand and would not expect more.
0
Sascha B

Sascha B

  • 0
  • 237
  • 0
Nov 30 2010 9:15 AM
uff, ok...

I only want to understand what you mean.
I have to create a contructor within the Tabcontrol class to choose another draw event(mode) right?
If so I try it and I'll come back if I have results.
0
Jean Paul

Jean Paul

  • 26
  • 43k
  • 9.4m
Nov 30 2010 9:08 AM
I believe you are referring to WinForms.

For achieving the same, you can do custom drawing on a subclassed tab control.
You may use a bool IsDirty to determine there are unsaved changes.

In the custom tab control constructor, add the following code.
if (!this.DesignMode)
            {
                this.DrawMode = TabDrawMode.OwnerDrawFixed;
                this.SizeMode = TabSizeMode.Fixed;
                this.DrawItem += new DrawItemEventHandler(DrawItemEvent);
            }

Then, create a new method

"void DrawItemEvent(object sender, DrawItemEventArgs e)"

which would handle the drawing event based on IsDirty.