How to setup ArrayList properties

When I set up the property of a user component, I use ->

public ArrayList Source {
  get {return rsource;} set {rsource = value;}
}

But the source has two properties - Name and ID. How can I set this up such that the Source property Object Collection Editor conatins the Name and ID Properties in the right pane when I add a new source.

Thanks,


Frank


Answer this question

How to setup ArrayList properties

  • Mark Marsh

    I am back to square one now... the Source is really -

    public class SourceClass
    {
    public string ID;
    public string Name;
    }

    But I need to delare that in the property as an ArrayList so different set of values can be entered in the property Listbox.

    ArrayList rsource;
    public ArrayList Source
    {
    get {return rsource;}
    set {rsource = value;}
    }

    Is this possible

    Frank

  • Hi Its Me

    Is "Source" an ArrayList   If so, I don't believe the properties have "ID", and "Name".
  • Paul Nolan

    Basically, you return the object, and from that, you can get the properties of that object.

    YourObject.Source.ID = 223;
    YourObject.Source.Name = "KraGiE";

  • Divyachandra

    KraGiE,

    I am not that far yet. I am still trying to define the property of "Source" so that when the component is compiled and then used by the test windows program, the property window of the component shows the members (name and ID) of "Source" on the right pane when added. Can you be kind enough to show a few more lins of code

    Thanks,


    Frank

  • jgrant

    I need to have Source as an ArrayList of a set of properties. Each source has Name, ID, Location. etc.. After the component is dropped, user can add the sources and define th eproperty of each source just like the "Tab" component. Each Tab is the same and you can add many tabs. While I can add an ArrayList property but don't know how to setup the member properties of each source.

    Thanks,

    Frank

  • thePrisoner06

    ooohhh, I get it now.  Sorry, it totally makes sense to me now.  My mind's been all over the place today.

    Anyways, with the ArrayList, it's a little tricky because it contains objects.  Therefore, you're going to have to cast the object into the type you need it to become.

    for example..

    Source tempSource = (Source) YourObject.Source[0];


    Once you've done that, you can return the correct values from the properties in the actual object you are storing in the ArrayList.  You have to keep in mindn that ArrayList is a collection object.  That's why it rests in System.Collections namespace.  

    I'm not sure if you understand or not, but you have to iterate through the ArrayList to get the object you wish to display values from.


  • Ney André de Mello Zunino

    Another way to ask the question could be ->

    Look at the TableStyles property of the dataGrid. When you add a Style, there is a corresponding set of properties.  How is the Get/Set properties done for this "TableStyles" property done. This is exactly what I am looking for.


    Frank

  • How to setup ArrayList properties