object properties presentation


S

Smola

Hi all,

Which is the best way to present (for editing as well) object
properties?

PropertyGrid, flipped DataGridView or maybe something else?

The control should be able to inherently display property names and
adequate editors (for dates, strings, ints, lists, etc..).


And another question is what if my object is an array, or a list, which
contains different types of objects.

I tried to set an array to the PropertyGrid control but I don't know how
to display custom item names as property names. :(
 
Ad

Advertisements

M

Mr. Arnold

Smola said:
Hi all,

Which is the best way to present (for editing as well) object
properties?

PropertyGrid, flipped DataGridView or maybe something else?

The control should be able to inherently display property names and
adequate editors (for dates, strings, ints, lists, etc..).

You can collect the data in a grid that's based on a collection of objects
that populated the grid. However, you must take the data from the grid and
find the corresponding object in the collection and update the object.
That's why the object has propertie get/set, whereas, as you get data from a
property or set data on the property of an object.

If you're on row 2 of a grid that was populated by a collection of 10
objects, upon the completion of the edit on the grid row, you must update
the corresponting object.

You know what row you're on in the grid. So, smolas had 10 somola(s) in
smolas.

It would be something like smolas[1].Name = row[1].Name, if you're on row 2
base 10 from 0-9 idx.
And another question is what if my object is an array, or a list, which
contains different types of objects.

You can have differnt types of objects in an ArrayList(). However, you have
to know who those objects are at the time of addressing the object. You
can't take mixed objects in an ArrayList(s) and bind the ArrayList() to a
control. It must be all Smolas in the ArrayList() or all Arnolds. You can't
have both in the ArrayList(), which is not a typed safe ArrayList().
List<Smola> is a type safe collection, becuase they are all the same.
List<String> can only have strings in it. List<int> can only have ints in
it.

Do you understand?
I tried to set an array to the PropertyGrid control but I don't know how
to display custom item names as property names. :(

I don't know what you're talking about here. If all the objects in the
collection are the same object, then you simply bind the collection to the
control, and the grid will figure it out or you customize the grid control
and take control.




__________ Information from ESET NOD32 Antivirus, version of virus signature database 4121 (20090601) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
S

Smola

"Mr. Arnold" said:
You can collect the data in a grid that's based on a collection of objects
that populated the grid. However, you must take the data from the grid and
find the corresponding object in the collection and update the object.

Actually, I want to avoid to have to manually manage values between my
objects and the grid. Grid should do that. So if I pass an ArrayList to
a grid it shoud automaticaly update the right item in the list.

You can have differnt types of objects in an ArrayList(). However, you have
to know who those objects are at the time of addressing the object. You
can't take mixed objects in an ArrayList(s) and bind the ArrayList() to a
control. It must be all Smolas in the ArrayList() or all Arnolds. You can't
have both in the ArrayList(), which is not a typed safe ArrayList().

Yes, you can. Take a look here and download the example:

http://weblogs.asp.net/fbouma/pages/really-complex-databinding-
itypedlist-with-weakly-typed-collections.aspx

My problem now is that this grid is horizontal, and I would like to have
a vertical presentation, like in the PopertyGrid.

I don't know what you're talking about here. If all the objects in the
collection are the same object, then you simply bind the collection to the
control, and the grid will figure it out or you customize the grid control
and take control.

If you bind a collection to the PropertyGrid, the property names will
be: [0], [1], [2, [3] etc.. instead of e.g. "Name", "Address", "Phone"
etc..

And yes, you have to customize the collection by implementing
ICustomTypeDescriptor.

I think I'll go with PropertyGrid since you can customize editors for
each property.

However, it would be nice to have a vertical grid. I found some
approaches with flipping the grid cells but it's awkward, and also, I
don't want to deal with custom components.
 
M

Mr. Arnold

Smola said:
Actually, I want to avoid to have to manually manage values between my
objects and the grid. Grid should do that. So if I pass an ArrayList to
a grid it shoud automaticaly update the right item in the list.

Well, you can try.
Yes, you can. Take a look here and download the example:

http://weblogs.asp.net/fbouma/pages/really-complex-databinding-
itypedlist-with-weakly-typed-collections.aspx


You either use www.tinyurl.com

or you use www.somelongurl.com <> url in between the special characters
<url> to prevent word-wrap

There is nothing worse than having someone post an url that you have to
copy/past into a browser's address line.

And I'll put it to you point blank, when MS allowed binding to controls, all
it did was produce weak programmers.

That's just my opinion.

My problem now is that this grid is horizontal, and I would like to have
a vertical presentation, like in the PopertyGrid.

I don't know what you're talking about here. If all the objects in the
collection are the same object, then you simply bind the collection to
the
control, and the grid will figure it out or you customize the grid
control
and take control.

If you bind a collection to the PropertyGrid, the property names will
be: [0], [1], [2, [3] etc.. instead of e.g. "Name", "Address", "Phone"
etc..

And yes, you have to customize the collection by implementing
ICustomTypeDescriptor.

I think I'll go with PropertyGrid since you can customize editors for
each property.

However, it would be nice to have a vertical grid. I found some
approaches with flipping the grid cells but it's awkward, and also, I
don't want to deal with custom components.

A programmer can make things more complicated than they need to be. Most of
the time, simpler is better.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4122 (20090602) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
S

Smola

"Mr. Arnold" said:
Well, you can try.

Actually, I'm writing a set of binding classes so that the end-developer
can easely bind it to whatever it wants. Of course, I would like to give
him a possibility to bind to to the grid. I don't want to tell that he
has to write the controller logic as well.

And why would I write a binding mechanism if one already exists in the
framework?

You either use www.tinyurl.com

or you use www.somelongurl.com <> url in between the special characters
<url> to prevent word-wrap

There is nothing worse than having someone post an url that you have to
copy/past into a browser's address line.

I don't want to use those services, I have my reasons. And if someone
really wants the information it is worth the extra effort, wouldn't you
say?
And I'll put it to you point blank, when MS allowed binding to controls, all
it did was produce weak programmers.

That's just my opinion.

I'm sorry you feel that way.
 
Ad

Advertisements

M

Mr. Arnold

Smola said:
Actually, I'm writing a set of binding classes so that the end-developer
can easely bind it to whatever it wants. Of course, I would like to give
him a possibility to bind to to the grid. I don't want to tell that he
has to write the controller logic as well.

And why would I write a binding mechanism if one already exists in the
framework?



I don't want to use those services, I have my reasons. And if someone
really wants the information it is worth the extra effort, wouldn't you
say?

There is nothing stopping you from doing <someurl> within the special
characters of <> to prevent the url from wrapping.

<http://weblogs.asp.net/fbouma/pages...itypedlist-with-weakly-typed-collections.aspx>

Do you see the simplicity of putting the url between <> or <url> to prevent
word wrap or even if it did wrap, you can still click on it and not do a
copy/paste operation on it?

And if you want to know how to bind objects/classes to controls using
IBindingList etc, etc, then I suggest you go get one of the books, it will
show you how to do it, whereas, you can roll your own using the .Net
Framework.

http://www.lhotka.net/Default.aspx





__________ Information from ESET NOD32 Antivirus, version of virus signature database 4122 (20090602) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
Ad

Advertisements

S

Smola

"Mr. Arnold" said:
There is nothing stopping you from doing <someurl> within the special
characters of <> to prevent the url from wrapping.

<http://weblogs.asp.net/fbouma/pages...itypedlist-with-weakly-typed-collections.aspx>

Cool. I didn't know that.
And if you want to know how to bind objects/classes to controls using
IBindingList etc, etc, then I suggest you go get one of the books, it will
show you how to do it, whereas, you can roll your own using the .Net
Framework.

I don't belive in buying books for money. I belive in good people
sharing their knowledge for free. :)
 

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