C#:透明按鈕


 

設置btn FlatStyle為: Flat

設置btn背景為:Transparent

 

 

 

 

 

 

 

 

更徹底的話就要使用如下方法————

/// <summary>

/// 設置透明按鈕樣式

/// </summary>

private void SetBtnStyle(Button btn)  //在Form1_Load時候調用
{

    btn.FlatStyle = FlatStyle.Flat;//樣式

    btn.ForeColor = Color.Transparent;//前景

    btn.BackColor = Color.Transparent;//去背景

    btn.FlatAppearance.BorderSize = 0;//去邊線

    btn.FlatAppearance.MouseOverBackColor = Color.Transparent;//鼠標經過

    btn.FlatAppearance.MouseDownBackColor = Color.Transparent;//鼠標按下

}

private void btn_MouseHover(object sender, EventArgs e)  //分別設置進你要令其透明控件的動作

{

    Button btn = sender as Button;

    btn.FlatAppearance.BorderSize = 1;

}



private void btn_MouseLeave(object sender, EventArgs e)  //分別設置進你要令其透明控件的動作
{ 

  Button btn
= sender as Button; btn.FlatAppearance.BorderSize = 0;
}

 

來自:

http://greatverve.cnblogs.com/archive/2012/03/13/Transparent-button.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM