How could I know the parent of a GridItem in PropertyGrid

G

Guest

In propertyGrid1_PropertyValueChanged event, I want to know the changedItem's parent
For example, the changed item is Bold, its parent is Font. But how could I get the Font GridItem
I tried to use these codes
0->private void propertyGrid1_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e
1->
2-> GridItem item = e.ChangedItem
3-> if(item.Parent!=null
4->
5-> this.label1.Text = item.Parent.Label
6->
7-> els
8-> this.label1.Text = "null"
9->
But there will throw an exception at Line 3
The exception i
An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dl
Additional information: Cannot access a disposed object named "The GridItem has been disposed and is no longer usable."

Then I changed the codes at Line 2 like this
GridItem item = this.propertyGrid1.SelectedGridItem

The exception also be thrown
Who can tell me why and if I really need to get the GridItem's parent. How could I do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top