如何在PropertyValueChanged事件中获取PropertyGrid标签和GridItem标签 [英] How to get PropertyGrid tag and GridItem tag in PropertyValueChanged event

查看:375
本文介绍了如何在PropertyValueChanged事件中获取PropertyGrid标签和GridItem标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个窗口申请表.表单上有一个buuton,单击它时,popram将创建一个新的PropertyGrid,并为其设置一些功能,如下所示:

I write a window application form. There is one buuton on the form, when click it, the popram will create a new PropertyGrid, and set some features for it as below :

PropertyGrid NewPropertyGrid = new PropertyGrid();
NewPropertyGrid.tag = CheckString;
NewPropertyGrid.PropertyValueChanged += new PropertyValueChangedEventHander(NewPropertyGrid_PropertyValueChanged);
NewPropertyGrid.SelectedObject = NewObject;



当用户更改PropertyGrid的GridItem中的值时,将调用以下事件.



When user changes the value in the PropertyGrid''s GridItem, the event below will be invoked.

void NewPropertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)



现在的问题如下:

如何获取PropertyGrid的对象,以便获取其标记(例如PropertyGrid.tag)并在此事件中做进一步检查?



The question now is below :

How can I get the object of the PropertyGrid, so that I can get its tag (eg PropertyGrid.tag) and do further check in this event ?

推荐答案

void NewPropertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)



在这里,"s"将为您提供PropertyGrid作为对象.您需要投射并使用它

更新1 :
您还可以检查 e.OriginalSource .


更新2 :
你应该像这样,



Here "s" will give you the PropertyGrid as object. You need to cast it and use it

Update 1:
You can also check e.OriginalSource.


Update 2:
You are supposed to cast like,

((PropertytyGrid)s).Tag







or

(s as PropertyGrid).Tag




将其标记为有帮助的答案




Mark it as answer if it helps you


这篇关于如何在PropertyValueChanged事件中获取PropertyGrid标签和GridItem标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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