Winform中的垂直制表符控件 [英] Vertical tab control in winform

查看:76
本文介绍了Winform中的垂直制表符控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Alignment属性更改为Left或Right.但是文本为垂直形状,我该怎么办?
谢谢.

I changed Alignment property to Left or Right.but the text is in vertical shape.what can I do?
Thank You.

推荐答案

如果希望水平对齐文本,则需要将DrawMode设置为OwnerDrawFixed.然后在DrawItem事件上,手动绘制控件,如:

If you wish to have the text aligned horizontally you need to set the DrawMode to OwnerDrawFixed. Then on the DrawItem event, manually draw the control like:

private void tabControl_DrawItem(object sender, DrawItemEventArgs e)
{
    string tabName = tabControl.TabPages[e.Index].Text;
    StringFormat stringFormat = new StringFormat();
    stringFormat.Alignment = StringAlignment.Center;
    stringFormat.LineAlignment = StringAlignment.Center;
    //Find if it is selected, this one will be hightlighted...
    if (e.Index == tabControl.SelectedIndex)
        e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);
    e.Graphics.DrawString(tabName, this.Font, Brushes.Black,        tabControl.GetTabRect(e.Index), stringFormat);
}


这篇关于Winform中的垂直制表符控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆