+ Reply to Thread
Results 1 to 2 of 2

Thread: C# DataTable and adding new columns to a ListObject

  1. #1
    Registered User
    Join Date
    12-13-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    C# DataTable and adding new columns to a ListObject

    Hi,

    I've created a DataSet and within that I've created a DataTable and a TableAdapter. I have then used this to add a ListObject to a worksheet. However, I've now added a new column to the DataTable and want to add this to the ListObject without having to delete and re-create the ListObject. Is there a way of doing this ?

    I'm using Visual Studio 2008 and Excel 2007.

    Thanks
    Dave

  2. #2
    Registered User
    Join Date
    04-19-2010
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: C# DataTable and adding new columns to a ListObject

    Are you using a listBox or a listView? ListBoxes will not do multi column without some creative constructor overrides apparently.
    List Views will by using...
    (Set the view property to details, and there is a colums property collection that you can edit.)
                ListViewItem myItem = new ListViewItem();
                myItem.Text = person1.FirstName;
                myItem.SubItems.Add(person1.LastName);
                myItem.SubItems.Add(person1.Age.ToString());
    
    
                listView1.Items.Add(myItem);
    Set the view property to details, and there is a colums property collection that you can edit.

    I'm sort of a .NET newbie myself and maybe they are wanting to repurpose the listbox object. I can't seem to find anything about multiple columns like you could in VB6.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0