c#TabControl控件左边选项卡左边显示,文字横向显示
发布时间:2021-07-06 05:55:09 所属栏目:大数据 来源: https://blog.csdn.net/kasama1
导读:c#TabControl控件左边选项卡左边显示,文字横向显示 2015-12-17 10:50 ? 259人阅读 ? 评论(0) ? 收藏 ? 举报 @H_301_18@ ? 分类: c#开发(6)? 版权声明:本文为博主原创文章,未经博主允许不得转载。 ?代码简单移动 public class TabControlNF : System.Win
c#TabControl控件左边选项卡左边显示,文字横向显示
2015-12-17 10:50?
259人阅读?
评论(0)?
收藏?
举报
@H_301_18@
版权声明:本文为博主原创文章,未经博主允许不得转载。 ?代码简单移动 public class TabControlNF : System.Windows.Forms.TabControl ? ? {? ? ? ? public TabControlNF() ? ? ? ? { ? ? ? ? ? ? InitializeComponent(); ? ? ? ? ? ? TabSet(); ? ? ? ? } ? ? ? ? /// <summary> ? ? ? ? /// 设定控件绘制模式 ? ? ? ? /// </summary> ? ? ? ? private void TabSet() ? ? ? ? { ? ? ? ? ? ? this.DrawMode = TabDrawMode.OwnerDrawFixed; ? ? ? ? ? ? this.Alignment = TabAlignment.Left; ? ? ? ? ? ? this.SizeMode = TabSizeMode.Fixed; ? ? ? ? ? ? this.Multiline = true; ? ? ? ? ? ? this.ItemSize = new Size(50,210); ? ? ? ? } ? ? ? ? /// <summary> ? ? ? ? /// 重绘控件 ? ? ? ? /// </summary> ? ? ? ? /// <param name="sender"></param> ? ? ? ? /// <param name="e"></param> ? ? ? ? private void tabLeft_DrawItem(object sender,DrawItemEventArgs e) ? ? ? ? { ? ? ? ? ? ? Graphics g = e.Graphics; ? ? ? ? ? ? Font font = new Font("微软雅黑",10.0f);? ? ? ? ? ? ? SolidBrush brush = new SolidBrush(Color.Black); ? ? ? ? ? ? RectangleF tRectangleF = GetTabRect(e.Index); ? ? ? ? ? ? StringFormat sf = new StringFormat();//封装文本布局信息? ? ? ? ? ? ? sf.LineAlignment = StringAlignment.Center; ? ? ? ? ? ? sf.Alignment = StringAlignment.Near; ? ? ? ? ? ? g.DrawString(this.Controls[e.Index].Text,font,brush,tRectangleF,sf); ? ? ? ? } ? ? ? ? private void InitializeComponent() ? ? ? ? { ? ? ? ? ? ? this.SuspendLayout(); ? ? ? ? ? ? this.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.tabLeft_DrawItem); ? ? ? ? ? ? this.ResumeLayout(false); ? ? ? ? } ? ? } 结果显示
(编辑:北几岛) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |