【发布时间】:2019-09-13 22:45:46
【问题描述】:
我目前正在开发一个 WinForms 应用程序,我希望用户单击一个按钮,然后更改按钮文本。我有 11 个按钮,为每个按钮设置 MouseUp、MouseDown、Click 的方法会导致大量工作和重复非常相似的代码。
我做了一个类,但不知道如何处理用户点击的按钮。
public class AddButton
{
public int Count { get; set; }
private void Button_Click(object sender, EventArgs e)
{
Count++;
?ProductButton?.Text = Count + " Added";
}
}
如果需要,请单击this 链接下载完整的 WinForms 项目。
【问题讨论】: