我有一个称为ToolStripMenuItem
的myMenu
。我怎样才能这样访问:
/* Normally, I would do: */
this.myMenu... etc.
/* But how do I access it like this: */
String name = myMenu;
this.name...
这是因为我正在从XML文件动态生成ToolStripMenuItems,并且需要通过其动态生成的名称来引用MenuItem。
最佳答案
使用Control.ControlCollection.Find方法。
尝试这个:
this.Controls.Find()