[VB.NET,C#.NET] - TabControl的Alignment为Left或Right显示TabPage.Text问题

[VB.NET,C#.NET] - TabControl的Alignment为Left或Right显示TabPage.Text问题,第1张

概述VB.NET Private Sub  TabControl1_DrawItem( ByVal  sender  As  System.Object,  ByVal  e  As  System.Windows.Forms.DrawItemEventArgs)  Handles  TabControl1.DrawItem     ' Me.TabControl1.DrawMode = TabDra

VB.NET

Private Sub TabControl1_DrawItem( ByVal sender As System.Object, e System.windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
' Me.TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed ' 必须先改变模式(可将此句放在Load事件上)
Dim tabarea Rectangle
tabTextArea RectangleF
tabarea
= TabControl1.GetTabRect(e.Index)
tabTextArea
CType (TabControl1.GetTabRect(e.Index),RectangleF) g Graphics e.Graphics
sf StringFormat New StringFormat()
sf.lineAlignment
Stringalignment.Center
sf.Alignment
Stringalignment.Center Font Font Me .TabControl1.Font
brush SolIDBrush SolIDBrush(color.Black)
g.DrawString((
(sender,TabControl)).TabPages(e.Index).Text,Font,brush,tabTextArea,sf)
End Sub
C#.NET

private voID tabControl1_DrawItem(object sender,DrawItemEventArgs e){    //this.tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed;  必须先改变模式(可将此句放在Load事件上)    Rectangle tabarea;    RectangleF tabTextArea;    tabarea = tabControl1.GetTabRect(e.Index);    tabTextArea = (RectangleF)tabControl1.GetTabRect(e.Index);    Graphics g = e.Graphics;    StringFormat sf = new StringFormat();    sf.lineAlignment = Stringalignment.Center;    sf.Alignment = Stringalignment.Center;    Font Font = this.tabControl1.Font;    SolIDBrush brush =  SolIDBrush(color.Black);    g.DrawString(((TabControl)(sender)).TabPages[e.Index].Text,sf);}
总结

以上是内存溢出为你收集整理的[VB.NET,C#.NET] - TabControl的Alignment为Left或Right显示TabPage.Text问题全部内容,希望文章能够帮你解决[VB.NET,C#.NET] - TabControl的Alignment为Left或Right显示TabPage.Text问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1285765.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存