Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 c# 中使用用户控件,我想创建一个具有属性的用户控件,该属性具有使用用户控件的表单的所有按钮列表谢谢
像这样的东西?
public IEnumerable<Button> Buttons { get { List<Button> buttons = new List<Button>(); foreach (Control ctrl in ParentForm.Controls) { Button btn = ctrl as Button; if (btn != null) { buttons.Add(btn); } } return buttons; } }