【发布时间】:2014-07-29 04:05:36
【问题描述】:
我已经搜索了将近一个星期,但我似乎无法解决我的简单问题。我想获取项目中所有表单的所有名称和文本属性。
这是我的代码:
using System.Reflection;
Type Myforms = typeof(Form);
foreach (Type formtype in Assembly.GetExecutingAssembly().GetTypes())
{
if (Myforms.IsAssignableFrom(formtype))
{
MessageBox.Show(formtype.Name.ToString()); // shows all name of form
MessageBox.Show(formtype.GetProperty("Text").GetValue(type,null).ToString()); // it shows null exception
}
}
我需要表单的名称和.Text 将其存储在数据库中以控制用户权限。
【问题讨论】:
-
感谢您纠正 Dijkgraaf。
标签: c# winforms text types getproperty