我已经搜索了将近一个星期,但我似乎无法解决我的简单问题。我想获取项目中所有表单的所有名称和文本属性。
这是我的代码:
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
表单存储在数据库中以控制用户权限。