private void button1_Click(object sender, EventArgs e)
{
Type t = typeof(System.Drawing.Color);
string className = t.Name;
MessageBox.Show(className);
//获取所有方法
System.Reflection.MethodInfo[] methods = t.GetMethods();
this.textBox1.Text = "";
foreach (System.Reflection.MethodInfo method in methods)
{
this.textBox1.Text += method.Name + System.Environment.NewLine;
}
//获取所有成员
System.Reflection.MemberInfo[] members = t.GetMembers();
//获取所有属性
System.Reflection.PropertyInfo[] properties = t.GetProperties();
foreach (System.Reflection.PropertyInfo property in properties)
{
this.lstColors.Items.Add(property.Name);
}
}
private void lstColors_SelectedIndexChanged(object sender, EventArgs e)
{
this.pictureBox1.BackColor= System.Drawing.Color.FromName(((ListBox)sender).Text);
}
近期评论