How to find index of selected property in propertygrid

F

FUnky

hi all,

i would like to find the index of selected property in the propertygrid.
also, after editing the value of any particular property, i would like to
verify it and revert it to its previous (verified) value, if it fails
verification.
Can somebody plz guide me to do this.

Thanks in advance.

FUnky
 
S

Stoitcho Goutsev \(100\)

FUnky,

PropertyGrid has a property called SelectedGridItem where you can get the
currenlty selected item. The grid also fires an event PropertyValueChanged
that passes the old value for the property.

As far as veryfication goes this is usually done in the object itself; not
by the property grid. What you need to do is to implement the property
setter to check for valid values and if the value is not OK you just throw
an exception. The property grid will catch the exception and show a message
box. Then the user has the option to revert to the old value by pressing the
ESC key.

Other place where verification can happen in the type's TypeConverter. The
type converter also my filter out or fake members to the property gird.
 
F

FUnky

PropertyGrid has a property called SelectedGridItem where you can get the
currenlty selected item. The grid also fires an event PropertyValueChanged
that passes the old value for the property.
I need the index of property in the grid, which i cannot access from the
SelectedGridItem property.
 
S

Stoitcho Goutsev \(100\)

FUnky,

I don't know if it's possible. How do you define the index though? There are
expandable properties that change all the indexing when expanded/collapsed.
Maybe if you elaborate a bit more on your problem there could be another
solution.
 
F

FUnky

Hi Stoitcho,

Maybe the following explains the situation :

Type
Property
Index

Single Row
A
0

Expandable
B
1,0


B1
1,1


B2
1,2

Single Row
C
2
 

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