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