Results 1 to 3 of 3

Thread: Using a SortedList as a datasource to a Datagrid

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    London
    Posts
    63

    Using a SortedList as a datasource to a Datagrid

    Anyone know how I can use a SortedList of objects and display this contents of the SortList objects in a DataGrid.

    one row for each object in the list;

    i.e. my object

    public class MyObject
    {
    public MyObject()
    {
    //Constructor
    }

    public string name;
    public string address;
    }

    add 100 objects of my class above to MySortedList. each with a different name and address.

    How would I bind MySortedList to the Datagrid

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I am not one hundred percent sure, but I think you need to set the datasource equal to your list, and set the datamember equal to the actual property of your class you want to bind to. You might have to also implement an interface to allow you to bind to the objects as a datasource...not sure.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    London
    Posts
    63
    Got it sorted now.



    I Set the datasource to my sorted list, and then in my class I added some public get/set properties to allow data access.

    The databinding process picks up the fact that you have these public properties visible in your class and uses them as the grid columns.

    Now to set the header text !! which is not proving easy.

    Where's good ol' Flexgrid when you need it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width