我已经接近找到了一个解决方案,只是这一点小细节还差一步。
我的目标:
我想通过编写代码来更改表单(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;
}
请问有人能给我一些提示吗?
非常感谢
Evan