欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

C#更改tabControl選項(xiàng)卡顏色的方法

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C#教程|點(diǎn)擊: 次

本文實(shí)例講述了C#更改tabControl選項(xiàng)卡顏色的方法。分享給大家供大家參考,具體如下:

private void Form1_Load(object sender, EventArgs e)
{
  this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
  this.tabControl1.DrawItem += new DrawItemEventHandler(this.tabControl1_DrawItem);
}
private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
  StringFormat sf = new StringFormat();
  sf.LineAlignment = StringAlignment.Center;
  sf.Alignment = StringAlignment.Center;
  if (e.Index == tabControl1.SelectedIndex)
    e.Graphics.FillRectangle(Brushes.Red, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
  else
    e.Graphics.FillRectangle(Brushes.White, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
  e.Graphics.DrawString(((TabControl)sender).TabPages[e.Index].Text,
  System.Windows.Forms.SystemInformation.MenuFont, new SolidBrush(Color.Black), e.Bounds, sf);
}

1.在Form類的構(gòu)造函數(shù)中添加下列語句:

this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tabControl1.DrawItem += new DrawItemEventHandler(this.tabControl1_DrawItem);

2.實(shí)現(xiàn)下列函數(shù):

private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
   Font fntTab;
   Brush bshBack;
   Brush bshFore;
   if ( e.Index == this.tabControl1.SelectedIndex)
   {
     fntTab = new Font(e.Font, FontStyle.Bold);
     bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, SystemColors.Control, SystemColors.Control, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
     bshFore = Brushes.Black;
   }
   else
   {
     fntTab = e.Font;
     bshBack = new SolidBrush(Color.Blue );
     bshFore = new SolidBrush(Color.Black);
   }
   string tabName  = this.tabControl1.TabPages[e.Index].Text;
   StringFormat sftTab = new StringFormat();
   e.Graphics.FillRectangle(bshBack, e.Bounds);
   Rectangle  recTab = e.Bounds;
   recTab = new Rectangle( recTab.X,  recTab.Y + 4,  recTab.Width,  recTab.Height - 4);
   e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab);
}

更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#常見控件用法教程》、《C#面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》及《C#程序設(shè)計(jì)之線程使用技巧總結(jié)》

希望本文所述對(duì)大家C#程序設(shè)計(jì)有所幫助。

上一篇:C# partial關(guān)鍵字說明

欄    目:C#教程

下一篇:C#簡(jiǎn)單實(shí)現(xiàn)防止多個(gè)程序運(yùn)行的方法

本文標(biāo)題:C#更改tabControl選項(xiàng)卡顏色的方法

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6663.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有