我的这个项目有很多winform,我该如何更改button background color or text color or any other attributes from another winform
?我目前正在使用delegate
,这并不有效,因为每次我想更改新属性时都需要创建一个新的delegate
。有更好的方法吗?
在设计器中,单击按钮
确保GenerateMember
为true,Modifiers
为public。使用PascalCase命名按钮,例如CancelButton
现在你可以用其他形式:
var formWithButton = new FormX();
formWithButton.CancelButton.BackColor = Color.Black;
如果你要做大量的更改,也许可以考虑一个主题化框架,而不是