SMU*_*hah 5 c# tabcontrol tabpage winforms
当我将TabControl对齐设置为Left或者Right在选项卡按钮和标签页区域之间留下这个巨大的空间时.如何摆脱这个无用的空间?
TabControl.Appearance设置为Buttons因为如果设置为Normal按钮上的文本消失.

更新:
当我设置TabControl.Alignment到Bottom和TabControl.Appearance到Normal按钮看起来反转(橙色线应该低于)

当我设置TabControl.Alignment到Bottom和TabControl.Appearance到Buttons,没有任何一个领域上TabPage,以控制地方

这是本机选项卡控件的XP视觉样式实现的一个众所周知的问题,只有与顶部对齐的选项卡才能正确呈现.直到Windows 7才解决此错误.解决方法是有选择地关闭样式.在项目中添加一个新类并粘贴下面显示的代码.编译.将新控件从工具箱顶部拖放到表单上,然后根据自己的喜好更改Alignment属性.它看起来不会那么漂亮.
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
class FixedTabControl : TabControl {
protected override void OnHandleCreated(EventArgs e) {
SetWindowTheme(this.Handle, "", "");
base.OnHandleCreated(e);
}
[DllImportAttribute("uxtheme.dll")]
private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6304 次 |
| 最近记录: |