PropertyGrid control
ok, here is a neat control. the PropertyGrid.
if you are using
SharpDevelop
it should already be in your toolbox, but, if you are using
Visual Studio
then you should right click in the [Windows Forms]
window and choose [Add/Remove Items...] and
then find PropertyGrid and check the box beside it.
now you get to add it to your winforms projects and get to set/get
properties on your objects. it works just like the
[Properties] windows in either ide mentioned above.
give it an object setting the SelectedObject property
like
pgItem.SelectedObject = lbList.SelectedItem;
the example uses a listbox and cute little objects in it to
illustrate the use. anyway, here is the code:
With Line Numbers and
Without Line Numbers
the real work is done on lines 116 and 121 which are:
116: lbList.Items.Add(new TestObject());
and
121: pgItem.SelectedObject = lbList.SelectedItem;
which add a TestObject to the list and associate it with the PropertyGrid respectively. That is it. The PropertyGrid handles the rest, including the OpenFileDialog for the Image property.
|