C# TabControl中Tab放于左边并正常显示TabText - 小众知识

C# TabControl中Tab放于左边并正常显示TabText

2015-03-18 10:58:55 苏内容
  标签: C//TabControl
阅读:5756
/// <summary>
        /// 構造函數
        /// </summary>
        public TabL()
        {
            InitializeComponent();
            TabSet();
            tabLeft.DrawItem += new DrawItemEventHandler(tabLeft_DrawItem);
        }

        /// <summary>
        /// 設定控件繪製模式
        /// </summary>
        private void TabSet()
        {
            tabLeft.DrawMode = TabDrawMode.OwnerDrawFixed;
            tabLeft.Alignment = TabAlignment.Left;
        }
        /// <summary>
        /// 重繪控件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void tabLeft_DrawItem(object sender, DrawItemEventArgs e)
        {
            StringFormat sfForamt = new StringFormat();
            sfForamt.LineAlignment = StringAlignment.Center;
            sfForamt.Alignment = StringAlignment.Center;
            //sfForamt.FormatFlags = StringFormatFlags.DirectionVertical;
            TabControl tcTab = (TabControl)sender;
            e.Graphics.DrawString(tcTab.TabPages[e.Index].Text, SystemInformation.MenuFont, new SolidBrush(Color.Black), e.Bounds, sfForamt);

        }
扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1