小编典典

在C#中按名称获取Windows窗体控件

c#

我有一个ToolStripMenuItem电话myMenu。我如何这样访问:

/* Normally, I would do: */
this.myMenu... etc.

/* But how do I access it like this: */
String name = myMenu;
this.name...

这是因为我正在从XML文件动态生成ToolStripMenuItems,并且需要通过其动态生成的名称来引用MenuItems。


阅读 869

收藏
2020-05-19

共1个答案

小编典典

使用Control.ControlCollection.Find方法。

尝试这个:

this.Controls.Find()
2020-05-19