I have been searching for almost a week now, but I can't seem to solve my simple problem. I want to get all the name and text properties of all the forms in my project.
Here is my code:
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
}
}
I need the name and the .Text
of the form to store it in the database to control user privileges.