且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Windows 窗体中访问另一个窗体上的控件的***方法?

更新时间:2023-12-06 11:37:28

您可以创建控制其可见性的属性,而不是将控件设为公开:

Instead of making the control public, you can create a property that controls its visibility:

public bool ControlIsVisible
{
     get { return control.Visible; }
     set { control.Visible = value; }
}

这会为该控件创建一个适当的访问器,该访问器不会公开该控件的整个属性集.

This creates a proper accessor to that control that won't expose the control's whole set of properties.