开发者

How can I assign a custom backcolor or background image to a TabPage control?

开发者 https://www.devze.com 2023-02-07 10:15 出处:网络
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

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:

How can I assign a custom backcolor or background image to a TabPage control?

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


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:

  • http://homepage.ntlworld.com/mdaudi100/alternate/tabcontrols.html
  • http://www.codeproject.com/KB/tabs/flattabcontrol.aspx
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号