Results 1 to 2 of 2

Thread: Datagrid SelectedItem erros when populated with observablecollection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2012
    Posts
    136

    Datagrid SelectedItem erros when populated with observablecollection

    I've had lots of success using datagrids with datatables and because reliant on .SelectedItem(0) to get the ID of the datarow populating that row.

    I've gotten more complex and created an observablecollection of classes populated from a datatable and set the collection as the itemssource.

    Now SelectedItem(0) just gives me an error saying "no default member for for type myclass". I did make sure the ID was the first field in the class so it should be SelectedItem(0) as far as I know but I can't seem to figure out how to access it.

    How do I get data from the selected row when using an observablecollection?

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Dec 2012
    Posts
    136

    Re: Datagrid SelectedItem erros when populated with observablecollection

    ACK I just figured it out. I thought SelectedItem was reporting a datagrid item but it looks like it is in fact the item I provided to populate the grid! So just Ctype(SelectedItem,myClass) and I have everything! I thought that was too simple to be true but it works!

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