如何在WinForms中删除容器控件上的边框填充?

cnd*_*cnd 6 .net c# controls winforms

我将margin和padding设置为0 0 0 0,但这对我的TabControls没有任何影响.看:

在此输入图像描述

这就是我所说的.我想把边界粘在一起.

我怎样才能做到这一点?

@Henk Holterman - 是的,它有什么问题?

Han*_*ant 11

由一位恼怒的Microsoft程序员(为了适应页面而编辑),TabPage的源代码中留下了一条评论:

//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);
Run Code Online (Sandbox Code Playgroud)

Visual Styles是一个主要的bug工厂,特别是TabControl.检查此答案,以便有选择地为TabControl关闭它,这样您就可以获得您习惯的行为.当然它确实改变了外观.