C#垂直制表符控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8991507/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 05:28:52  来源:igfitidea点击:

C# vertical tab control

c#winforms

提问by Rocshy

Can I make a tab control to look like the attached picture? I managed to add a tab control, but the text is still vertical. And I would want it to be horizontal.

我可以使选项卡控件看起来像附加图片吗?我设法添加了一个选项卡控件,但文本仍然是垂直的。我希望它是水平的。

enter image description here

在此处输入图片说明

采纳答案by Lloyd

There is an MSDN article about how to achieve this. How to: Display Side-Aligned Tabs with TabControl

有一篇关于如何实现这一点的 MSDN 文章。如何:使用 TabControl 显示侧对齐的选项卡

The following procedure shows how to render right-aligned tabs, with the tab text running from left to right, by using the "owner draw" feature.

以下过程显示了如何使用“所有者绘制”功能呈现右对齐的选项卡,其中选项卡文本从左到右运行。

回答by silverspoon

Try this TabStripcontrol. I believe this is what you want.

试试这个TabStrip控件。我相信这就是你想要的。

回答by MyHealingLife

i think this is default selected color

我认为这是默认选择的颜色

private void tabControl1_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e)
{
...
if (e.State == DrawItemState.Selected)
    {

        // Draw a different background color, and don't paint a focus rectangle.
        _textBrush = new SolidBrush(Color.Black);
        g.FillRectangle(Brushes.White, e.Bounds);
    }
    else
    {
        _textBrush = new System.Drawing.SolidBrush(e.ForeColor);
        g.FillRectangle(Brushes.WhiteSmoke, e.Bounds); 
    }
...

image

图片