我想創建自定義按鈕。 無論按鈕是否添加了控件,它都會覆蓋Paint Event,並使顏色移動並從左向右填充,這看起來像是進度條。覆蓋按鈕,使backcolor從左到右填充像進度條
這是我的邏輯。但是,我認爲這不是一個正確的方法。請建議正確的方法來獲得動畫BackColor。 此按鈕大小的代碼庫:
private void customButton()
{
Button customButton=new Button();
customButton.Size.width=1;
custonButton.BackColor=Color.Green;
this.Controls.Add(customButton);
for (int i = 0; i<50; i+= 5)
{
customButton.Size.width += 1;
}
}
但是,該代碼創造一個按鈕有寬度= 50像素,和寬度將從左向右擴大,像進度條 我想創造和超越默認OnPaint事件,創建一個按鈕有50個像素,當父控件添加backColor時,backColor將從左向右移動(動畫)。 我是C#的新手,對OnPaint事件不太瞭解。
你看了這裏:http://msdn.microsoft.com/en-us/library/vstudio/cksxshce(v=vs.100).aspx? – Cadde 2014-12-06 10:43:43
標籤是一個更好的控制來做到這一點。 – 2014-12-06 15:12:41