alexmen

专注.net软件开发,项目管理体系PMBOK.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 private void button1_Click(object sender, EventArgs e)
 2        {
 3            Type t = typeof(System.Drawing.Color);
 4            string className = t.Name;
 5            MessageBox.Show(className);
 6
 7            //获取所有方法
 8            System.Reflection.MethodInfo[] methods = t.GetMethods();
 9            this.textBox1.Text = "";
10            foreach (System.Reflection.MethodInfo method in methods)
11            {
12                this.textBox1.Text += method.Name + System.Environment.NewLine;
13            }

14
15            //获取所有成员
16            System.Reflection.MemberInfo[] members = t.GetMembers();
17
18            //获取所有属性
19            System.Reflection.PropertyInfo[] properties = t.GetProperties();
20            foreach (System.Reflection.PropertyInfo property in properties)
21            {
22                this.lstColors.Items.Add(property.Name);
23            }

24        }

25
26        private void lstColors_SelectedIndexChanged(object sender, EventArgs e)
27        {
28           this.pictureBox1.BackColor=  System.Drawing.Color.FromName(((ListBox)sender).Text);
29        }

posted on 2011-04-01 17:41  alexmen  阅读(3775)  评论(0编辑  收藏  举报