Advance Property Grid Manipulation

J

John Kraft

Hi all,

I'm trying to use a property grid, and what I'm trying to do seems to
really elude me. I've been using the property grid for a short period
of time, and this is the first thing I haven't been able to do.

I have some products... like t-shirts... and these products have
particular property / value pairs. I'd like the property grid to look
like this:

Category Clothing
Type T-Shirt
Properties
Color Purple
Material Cotton
Size XL

I'd even settle for something like:

Category Clothing
Type T-Shirt
Properties
Property
Name Color
Value Purple
Property
Name Material
Value Cotton

.... or...

Category Clothing
Type T-Shirt
Properties
[0]
Name Color
Value Purple
[1]
Name Material
Value Cotton

The problem is that I don't know the properties or the values. Both
are dynamic. That is that I have no idea what the properties (color
material size) or values (purple, cotton, xl) are. The product object
uses a SortedList<string, string> (i've also tried using arrays and
other structures) to store the key and value. And, additionally, I'd
like the value to be able to show a dropdown of all the possible
values for that key.

What I keep ending up with is something like:

Category Clothing
Type T-Shirt
Properties
Properties (Collection)

The collection brins up the collection editor, but I can't add or
change anything.

When I tried using arrays (and other structures), I ended up with
something like:

Category Clothing
Type T-Shirt
Properties
[0] Color
[1] Material
[2] Size

As you can see, neither of these is acceptable because it does not
give the user the desired editing capabilities of the above examples.
I've been using the MSDN article at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp
It has given me a really good starting point, but I just can't seem to
get any more out of the grid. Has anyone else attempted something
like this? Does anyone have any good examples or links?

Sincerely,

John Kraft
 
G

Greg Cadmes

Hi John,

I am writing you with the assumtion that you know something about .NETs
TypeConverter or the ExpandableObjectConverter classes.

Personally, I haven't had the need for custom (dynamic)
properties/values as you described in your post, however, I found
several PropertyGrid articals on CodeProject.com where each example
implements different flavors of the PropertyGrid. I am about to post my
first artical/example with code snippets and credits of all
PropertyGrid articals combined. Stay tuned...it will be a more
advanced PropertyGrid with all the trimmings. (including- dynamic
properties, tabbing through GridItems, PropertySorting, dynamic code
generation,...etc)

But since I havn't posted yet, here is (IMO) the best PropertyGrid
example that should get you in the direction you need to go.
http://www.codeproject.com/useritems/PropertyGridEx.asp

Cheers,
Greg Cadmes


John said:
Hi all,

I'm trying to use a property grid, and what I'm trying to do seems to
really elude me. I've been using the property grid for a short period
of time, and this is the first thing I haven't been able to do.

I have some products... like t-shirts... and these products have
particular property / value pairs. I'd like the property grid to look
like this:

Category Clothing
Type T-Shirt
Properties
Color Purple
Material Cotton
Size XL

I'd even settle for something like:

Category Clothing
Type T-Shirt
Properties
Property
Name Color
Value Purple
Property
Name Material
Value Cotton

... or...

Category Clothing
Type T-Shirt
Properties
[0]
Name Color
Value Purple
[1]
Name Material
Value Cotton

The problem is that I don't know the properties or the values. Both
are dynamic. That is that I have no idea what the properties (color
material size) or values (purple, cotton, xl) are. The product object
uses a SortedList<string, string> (i've also tried using arrays and
other structures) to store the key and value. And, additionally, I'd
like the value to be able to show a dropdown of all the possible
values for that key.

What I keep ending up with is something like:

Category Clothing
Type T-Shirt
Properties
Properties (Collection)

The collection brins up the collection editor, but I can't add or
change anything.

When I tried using arrays (and other structures), I ended up with
something like:

Category Clothing
Type T-Shirt
Properties
[0] Color
[1] Material
[2] Size

As you can see, neither of these is acceptable because it does not
give the user the desired editing capabilities of the above examples.
I've been using the MSDN article at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp
It has given me a really good starting point, but I just can't seem to
get any more out of the grid. Has anyone else attempted something
like this? Does anyone have any good examples or links?

Sincerely,

John Kraft
 

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