争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

如何设置tabcontrol控件的tabPage的text内容显示成竖着的字体

时间:2024/7/3作者:未知来源:争怎路由网人气:

Private tabArea As Rectangle
 Private tabTextArea As RectangleF

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed '设置用户绘制方式
        Me.TabControl1.Alignment = TabAlignment.Right '设置TAB项右对齐布局
        'TabControl1.SizeMode = TabSizeMode.Fixed ‘设置TAB项大小的方式(全都一样大小)
        'TabControl1.ItemSize = New Size(150, 20) '设置大小
    End Sub

    Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
        tabArea = TabControl1.GetTabRect(e.Index) '主要是做个转换来获得TAB项的RECTANGELF
        tabTextArea = RectangleF.op_Implicit(TabControl1.GetTabRect(e.Index))
        Dim g As Graphics = e.Graphics
        Dim sf As New StringFormat() '封装文本布局信息

        sf.LineAlignment = StringAlignment.Center
        sf.Alignment = StringAlignment.Center

        Dim p As New Pen(Color.Blue) '绘制边框的画笔
        Dim font As New Font("Arial", 10.0F)
        Dim brush As New SolidBrush(Color.Red)

        g.DrawRectangle(p, tabArea) '绘制边框
        '绘制文字
        g.DrawString(CType(sender, TabControl).TabPages(e.Index).Text, font, brush, tabTextArea, sf)
    End Sub




关键词:如何设置tabcontrol控件的tabPage的text内容显示成竖着的字体




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版