在Visual Studio中显示设计师的属性 [英] show properties in designer in visual studio

查看:82
本文介绍了在Visual Studio中显示设计师的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个带有Color属性的表单.如何在设计器模式下的属性窗口中显示它.

Hi I have a form with a Color property .How can I show it in properties window in designer mode .

推荐答案

如果您需要在表单中显示自己的属性设计窗口,您必须基于派生表单.

If you need to show a property of your own in the design window, you have to base a from on a derived form.
I.e.
public class MyFormWithProperty : Form
   {
   public int MyProperty { get; set; }
   public MyFormWithPropertyfrmTesting()
       {
       InitializeComponent();
       }
   }

,然后从中派生您的表单实例:

And then derive your form instance from that:

public class MyFormInstance : MyFormWithProperty
   {
   public MyFormInstance()
       {
       InitializeComponent();
       }
   }

当您查看MyFormInstance的属性时,它将具有MyProperty属性.

听起来令人困惑:但是只要尝试一下-您就会明白我的意思!

When you look at the properties for MyFormInstance, it will have the MyProperty property.

It sounds confusing: but just try it - you will see what I mean!


如果这是表单类的公共属性,则PropertyGrid会自动显示它.

—SA
If this is a public property of your form class, the PropertyGrid shows it automatically.

—SA


这篇关于在Visual Studio中显示设计师的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆