【发布时间】:2011-08-13 06:36:13
【问题描述】:
我已经非常接近找到解决这个问题的方法了;在这一点上只是漏掉了一个小细节。
我想做什么:
我想通过代码更改表单(Form1)上每个按钮的光标样式。我知道如何使用 foreach 搜索表单上的所有控件,但我不确定如何通过我编写的例程将此控件作为参数传递。我将在下面展示我正在执行的操作的示例。
private void Form1_Load(object sender, EventArgs e)
{
foreach (Button b in this.Controls)
{
ChangeCursor(b); // Here is where I'm trying to pass the button as a parameter. Clearly this is not acceptable.
}
}
private void ChangeCursor(System.Windows.Forms.Button Btn)
{
Btn.Cursor = Cursors.Hand;
}
有人可以给我小费吗?
非常感谢
埃文
【问题讨论】:
标签: c# winforms button controls