在PropertyGrid中下拉属性

编程入门 行业动态 更新时间:2024-10-25 20:18:19
本文介绍了在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 www.michaeltaylorp3

Michael Taylor www.michaeltaylorp3

更多推荐

在PropertyGrid中下拉属性

本文发布于:2023-11-12 12:49:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581538.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   PropertyGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!