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.
有什么方法可以像使用 List 集合一样在先前索引的面板中插入新控件,如下所示:
List.Insert(2,Value);
我正在使用 C# winforms。
我想这样做是因为我想按特定顺序访问控件,如下所示:
Control c = panelThumbnail.GetNextControl(control, true);
它按索引的顺序给出控件。有没有其他方法可以解决问题?
返回的控件顺序Control.GetNextControl基于所包含控件的 TabIndex。若要更改返回控件的顺序,请更改每个控件的 TabIndex 以匹配您希望它们返回的顺序。
Control.GetNextControl
您可以将新控件添加到控件数组中。然后您可以通过数组以任何顺序访问控件,而不是使用 .GetNextControl。