欢迎来ClickableButton!
有用和受欢迎克里斯蒙德"一个不可点击buttonquot;文章和类,我还以为是一个可点击按钮,也可能是有用的。虽然我ClickableButton类实现专为。NET中,同样的技术可以用在几乎所有的面向对象的窗口库。
样品
下面是一个使用ClickableButton类的样本。请注意,我们已经处理Click事件中表现出升值的消息框:
{S0}使用
要使用ClickableButton,将它添加到您的形式简单,无论是通过的WinForms设计师或手动,设置适当的属性:
行为class Form1 : Form {
ClickableButton button1;
...
void InitializeComponent() {
this.button1 = new ClickableButton();
...
this.button1.Location = new System.Drawing.Point(24, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(200, 120);
this.button1.TabIndex = 0;
this.button1.Text = "Click Me!";
this.button1.Click += new System.EventHandler(this.button1_Click);
...
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1});
...
}
}
注意从示例应用程序ClickableButton将显示本身作为与文字标签的阴影广场。当用户使用鼠标点击ClickableButton,它会采取一个郁闷的神情'N'的感觉,火Click事件,其中一个托管程序可以处理。例如,样品处理像这样的Click事件:{C}实施
我ClickableButton类从基类派生System.Windows.Forms.Button类的,绝对没有添加:
问题
public class ClickableButton : System.Windows.Forms.Button
{
}
尽管这个按钮是相当的功能,它几乎没有ChrisM的乐趣无法点击按钮。潜在的方式,使更多的乐趣,包括:
0;调用用户讨厌的名字。 格式quot; C:quot; 切换用户界面语言为西班牙语。 产卵病毒。 CPU过热。 重置用户的扫雷高分。|克里斯销售