.Net 属性网格。 有没有办法让网格以不同的方式操作对象
据我了解,属性网格被赋予一个对象,它可以通过使用反射提取其属性来操作该对象。
我的问题是我有一组在运行时确定的参数,因此我无法静态地组成一个具有属性的类来表示这组参数。
我有两个想法来解决这个问题,但这两个想法都很复杂,并且可能会消耗大量时间,事实上,我会说它们在我的时间限制下不切实际。 一种是使用 Reflection Emit 动态定义类,另一种是动态构建 C# 源文件,然后使用 CodeDom 编译它。
属性网格是否可以以不同的方式运行(除了使用反射提取对象的属性之外)来满足我的问题?
如果没有,您知道还有其他控件可以帮我完成这项工作吗?
我想说,我从一开始就使用属性网格的原因是它能够为常见类型提供非常好的数据检索 UI。对于颜色,您会自动获得调色板,对于数据时间,您会自动拥有一个不错的日历。 如果可能的话,我想自动获取这些东西。
As I understood , The property grid is given an object which it can manipulate by extracting its Properties using reflections.
My problem is that I have a set of Parameters that is determined during run-time , thus I can't staticly compose a class with properties to represent this set.
I have two idea in mind to solve this problem but both are complex and will probably consume lot of time , infact i will say they are not practical under my time constraints. One is to use Reflection Emit in order to define a class dynamically and the other is to dynamiclly build a C# source file and then compile it using CodeDom.
Can Property grid behave in a different manner( other then extracting the Properties of an object using reflections ) that can suite my problem?
If no do you know any other control that can do the job for me?
I want to say that the reason I went to the property grid from the begining was its ability to provide realy nice Data Retrieval UI for common types.For color you autometically get a palette , For dataTime you automatically have a nice calender. I would like to get those things automatically , If possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,通过使用
TypeConverter
、ICustomTypeDescriptor
中的任何一个,PropertyGrid
可以显示除编译时属性之外的内容。或TypeDescriptionProvider
提供运行时伪属性。 你能举例说明你的参数是什么样的吗? 我应该能够提供一个示例...这是一个基于 早期回复(相关但不同):
Yes,
PropertyGrid
can display things other than just the compile-time properties, by using any ofTypeConverter
,ICustomTypeDescriptor
orTypeDescriptionProvider
to provide runtime pseudo-properties. Can you give an example of what your parameters look like? I should be able to provide an example...here's a basic example (everything is
string
, etc) based on an earlier reply (related but different):