0

How can I assign a background image to tabpage control in Visual Studio C# 2010? I am able to provide background image to each of the tab separately, but I cannot do it so for the whole tabpage control, due to which a portion of tabpage control remain with different background and each of the tab pages has ok and fine background.

Here is the picture of my form:

C:\Documents and Settings\AWaheed3\Desktop\Stack Overflow.JPG

See the 'grey-colored' region in the tabs line. How can I cover the whole tabpage control with one single background?

halfer
  • 19,824
  • 17
  • 99
  • 186
Asad
  • 521
  • 2
  • 13
  • 30

1 Answers1

1

The header area that contains the tabs is not part of your tab page. It's part of the parent TabControl, which is automatically drawn for you by Windows.

If you want to change how it looks, you'll have to draw it yourself. That's called owner-drawing, and it's not exactly a trivial undertaking, especially for a complicated control like this one. For starters, you can't just use OwnerDrawFixed, because that just allows you to custom draw the contents of the tabs (for example, to change the font). You will need to owner draw the entire tab control.

I can't imagine a good reason that you would ever want do this, but you'll find a few samples online that might help get you started. For example:

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • Please tell me how to do this? – Asad Jan 31 '11 at 08:52
  • This background is my company logo, and I want to put it on my application! – Asad Jan 31 '11 at 08:53
  • @Asad: Um, I gave you two links that contain samples of how you do it. The first one is particularly good. Mick's "A Completely OwnerDraw TabControl" is exactly what you'll have to implement. Of course, you'll have to tweak the colors, etc. that it uses, but you're own your own for that. – Cody Gray - on strike Jan 31 '11 at 08:55
  • @Asad: And in response to your second comment about wanting to show your company logo, [Microsoft has a few thoughts on that](http://msdn.microsoft.com/en-us/library/aa511284.aspx). Namely, they suggest that Windows applications shouldn't be "over-branded" by the developer. Keep your logo in your program's About box and a few other strategic locations. Leave the user interface alone so that it matches the user's current theme. – Cody Gray - on strike Jan 31 '11 at 08:57