简体   繁体   English

VB.NET中的TabControl对齐问题

[英]Problem with TabControl alignment in VB.NET

I'm having a weird behaviour with a left-aligned TabControl in VB.NET. 我在VB.NET中使用向左对齐的TabControl有一种奇怪的行为。 Screenshot: 截图:

替代文字

What I wanted was to have the tabs literally the same way they would be if rotated 90 degrees to the left. 我想要的是使这些选项卡与向左旋转90度时的方式完全相同。

Does it have something to do with the fact I'm not (god forbid) using the standard XP theme? 这与我不是(上帝禁止)使用标准XP主题有关吗? Any solution to just make it work? 有什么解决办法可以使其正常工作吗? (Even if it's hard, but I don't want a control that has a contrasting style, I want the program looking consistent) (即使很难,但我不希望控件具有鲜明的风格,我希望程序看起来一致)

Thanks! 谢谢!

Happy ending: 美好的结局:

替代文字

Ok, I solved the issue. 好的,我解决了这个问题。 If someone else has the same problem, use this control . 如果其他人有相同的问题,请使用此控件 It's free under MIT license. 根据MIT许可,它是免费的。 Screenshot by the author: 作者截图:

替代文字

Note that the author made two controls. 请注意,作者进行了两个控制。 My advice: the second one has incorrect support for cleartype (It rotates after subpixel rendering), but it's easier to use, and has better padding control. 我的建议:第二个建议对cleartype的支持不正确(它会在子像素渲染后旋转),但更易于使用,并且具有更好的填充控制。 Go for it! 去吧! =) =)

EDIT If you use C++ and need it for that, there's an approach. 编辑如果您使用C ++并为此需要它,则有一种方法。 Picture of the result: alt text http://www.codeguru.com/dbfiles/get_image.php?id=6385&lbl=CXPTABCTRL_GIF&ds=20040309 结果图片: 替代文字http://www.codeguru.com/dbfiles/get_image.php?id=6385&lbl=CXPTABCTRL_GIF&ds=20040309
The author was very descriptive on how he did it, which is good, example: alt text http://www.codeguru.com/dbfiles/get_image.php?id=6385&lbl=CXPTABCTRL_RIGHT_GIF&ds=20040309 作者对自己的操作方式具有很好的说明性,这很好,例如: 替代文字http://www.codeguru.com/dbfiles/get_image.php?id=6385&lbl=CXPTABCTRL_RIGHT_GIF&ds=20040309
This is the link to the article. 是文章的链接。

Another very good approach is SkyBound's multi-purpose VisualStyles component. 另一个非常好的方法是SkyBound的多功能VisualStyles组件。 Seems that the binaries are free but the source is not, very fair deal. 似乎二进制文件是免费的,但源文件不是,很公平。 I'll check it out later, but if you need some visualstyles bug fixing, it seems like a choice. 稍后再检查,但是如果您需要修复一些visualstyles错误,这似乎是一个选择。
替代文字
(source: skybound.ca ) (来源: skybound.ca

from the authors: 来自作者:

first and foremost, it quashes XP theme bugs, silently, efficiently and automatically. 首先,它以无声,高效和自动的方式消除XP主题错误。 But it also provides a simple set of classes which you can use to draw your own controls using the Windows XP Theme API. 但是它还提供了一组简单的类,您可以使用这些类来使用Windows XP Theme API绘制自己的控件。

Check this . 检查一下 and more from the author. 还有更多来自作者。

Problem solved!! 问题解决了!! =D = d

Yes, it is a bug in the visual styles renderer for the tab control. 是的,这是选项卡控件的视觉样式渲染器中的错误。 Looks like you already found a replacement. 看来您已经找到了替代品。 Another low-impact approach is to selectively disable visual styles for the control. 另一种低影响的方法是有选择地禁用控件的视觉样式。 It will revert back to battle-ship gray, correctly drawing vertical tabs. 它将恢复为战斗舰灰色,并正确绘制垂直选项卡。 Tab page content will still render properly. 标签页内容仍将正确呈现。

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class FixedTabControl : TabControl {
  [DllImportAttribute("uxtheme.dll")]
  private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);

  protected override void OnHandleCreated(EventArgs e) {
    SetWindowTheme(this.Handle, "", "");
    base.OnHandleCreated(e);
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM