如何删除在的WinForms容器控件的边界填充?边界、控件、容器、WinForms

2023-09-04 00:20:43 作者:怣

我设置margin和padding为0,0 0 0,但是这并没有对我的任何的TabControls影响。你看:

I set margin and padding to 0 0 0 0 but that doesn't have any effect for my TabControls. Look:

下面是我在说什么。我要坚持的边界在一起。

Here is what I am talking about. I want to stick the borders together.

我怎样才能做到这一点?

How can I do this?

@Henk Holterman ? - 是的,有什么不对的地方。

@Henk Holterman - yes, what's wrong with it ?

推荐答案

还有留在源$ C ​​$下TabPage的评论由愤怒的微软程序员(编辑以适应页面):

There's a comment left in the source code for TabPage by an exasperated Microsoft programmer (edited to fit the page):

//HACK: to ensure that the tabpage draws correctly (the border will get 
//  clipped and gradient fill will match correctly with the tabcontrol).
//  Unfortunately, there is no good way to determine the padding used 
//  on the tabpage.
//  I would like to use the following below, but GetMargins is busted 
//  in the theming API:
//VisualStyleRenderer visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
//Padding themePadding = visualStyleRenderer.GetMargins(e.Graphics, MarginProperty.ContentMargins);

视觉风格是一个重要的错误工厂,特别是因此对于TabControl的。检查this回答一种方式,有选择地关闭它的​​TabControl的,所以你会得到你习惯的行为。当然,它的没有的改变外观。

Visual Styles have been a major bug factory, particularly so for TabControl. Check this answer for a way to selectively turn it off for the TabControl so you'll get the behavior you are used to. Of course it does change the appearance.