您好,
我正在为属性网格中的用户控件创建下拉属性,但我想将动态值传递给运行时下拉。
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 www.michaeltaylorp3
Michael Taylor www.michaeltaylorp3
更多推荐
在PropertyGrid中下拉属性
发布评论