Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2005

Tip: Looking for answers? Try searching our database.

Editing object in an ArrayList using the PropertyGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deleria010 - 27 Jul 2005 16:47 GMT
I have a class that I use a PropertyGrid to edit properties in.  I have
one property in the class that is an ArrayList.  The PropertyGrid
understands the ArrayList(displays Collection on the righthand side)
and lets me edit it(click on the '...' button and an object collection
editor window opens up).

When I try to edit the objects in the list using the collection editor
window, I can't because their properties and the values of the
properties on the righthand side are 'grayed out'.  I can add and
remove items but I can't change the value of the items I add because
the properties are 'grayed out'.  I want to be able to edit not only
the ArrayList but each item's value in the list. Is there anyway to do
this?

Here is the code that describes the property for the ArrayList:

        [CategoryAttribute("Camera Settings"),
        DescriptionAttribute("A list of exposure times in ms")]
        public ArrayList ExposureTimes
        {
            get
            {
                return this.exposureTimes;
            }
            set
            {
                this.exposureTimes = value;
            }
        }

Thanks for your time,
Kristin
deleria010 - 01 Aug 2005 16:47 GMT
I have found some work arounds.  If the variable is an array of native
types, the PropertyGrid has no problem displaying the values so that
they can be edited.  But this opens up the problem of managing the
array yourself, which an ArrayList takes care of.

So I created my own array list class that expands the list as needed
and provides all the methods that I was already using.  I had to add a
hint to have the PropertyGrid display the values in the array so that
the user can edit them.

[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
just above the class.

What gets displayed in the PropertyGrid is a bit weird.  There is the
variable of type MyArrayList than under that, a variable of the actual
array list, then you can expand the array to see and edit the actual
contents of the array.  It is not the most ideal solution but it works
for what I need it to do.

Kristin

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.