问题描述
我写了一个窗口申请表.表单上有一个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 :
更新2 :
你应该像这样,
Here "s" will give you the PropertyGrid as object. You need to cast it and use it
Update 1:
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标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!