哈哈是不是丑死了?
做了一个不停变色的按钮,可以通过勾选checkbox停下来,代码如下:
复合控件果然简单呀,我都能学会~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ComponentComposite
{
[ToolboxBitmap(typeof(Timer))]
public partial class Component1:UserControl
{
private Color _colFColor;
private Color _colBColor;
public Color colFColor { get { return _colFColor; } set { _colFColor = value; checkBox1.ForeColor = _colFColor; } }
public Color colBColor { get { return _colBColor; } set { _colBColor = value; checkBox1.BackColor = _colBColor; } }
public Component1()
{
InitializeComponent();
} public Component1(IContainer container)
{
container.Add(this); InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)
{ Random rdm=new Random();
int i1=rdm.Next(,);int i2=rdm.Next(,);int i3=rdm.Next(,);
button1.BackColor = System.Drawing.Color.FromArgb(i1, i2, i3);
} private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
timer1.Enabled = (timer1.Enabled)?false:true;
}
}
}
上午跟人家学了一个渐变按钮,
如图,现在试试可不可以组合。嗯可以组合,但是好像不是自动变化颜色的呀