在PropertyGrid中下拉属性 [英] Drop Down Property in PropertyGrid

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

问题描述

您好,

我正在为属性网格中的用户控件创建下拉属性,但我想将动态值传递给运行时下拉。

I am creating drop down property for user control in property grid, but I wanted to pass dynamic values to drop down at runtime.

我使用枚举传递静态值来下拉但我如何将动态值传递给枚举。

I am using enum to pass static values to drop down but how I can pass dynamic values to enum.

推荐答案

"但我如何将动态值传递给枚举。"

"but how I can pass dynamic values to enum."

枚举是编译时常量,因此您不能使用枚举并使其成为动态值。这没有意义。此外,将显示值的属性将是强类型的,因此属性的类型确定显示哪个控件

Enums are compile time constants so you cannot use an enum and also make it a dynamic value. That doesn't make sense. Additionally the property for which the value will be shown is going to be strongly typed so the type of the property determines what control gets shown.

通过正确地注释属性或其类型,您可以控制在属性网格中显示的内容。但是,对于属性或属性类型的改变而言,这些都不是动态的,因为它们在编译时是固定的。

By properly annotating the property or its type you can control what gets shown in the property grid. But none of that will be dynamic in the sense of it'll change for a property or a property's type as, again, they are fixed at compile time.

Michael Taylor

http://www.michaeltaylorp3.net

Michael Taylor
http://www.michaeltaylorp3.net


这篇关于在PropertyGrid中下拉属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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