Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problem in Binding datagrid control to Arraylist

Problem in Binding datagrid control to Arraylist

Scheduled Pinned Locked Moved Visual Basic
wpfwcfhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    V G
    wrote on last edited by
    #1

    Hi, I am binding my DataGrid control to an arrayList that contains strings as datagrid1.datasource = str where str is the ArrayList. On executing the code, the datagrid displays the length of the strings instead of the strings themseleves. How do i make the datagrid display the strings contained in the arraylist and not the length. Thanks!

    D 1 Reply Last reply
    0
    • V V G

      Hi, I am binding my DataGrid control to an arrayList that contains strings as datagrid1.datasource = str where str is the ArrayList. On executing the code, the datagrid displays the length of the strings instead of the strings themseleves. How do i make the datagrid display the strings contained in the arraylist and not the length. Thanks!

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This is actually by design that this happens. An array doesn't implement the databinding interfaces, so the DGV looks at the only property that it can find on each element, Length. You'd have to expose the array in a wrapper class that exposes the text of the string as a property. You cannot bind to the string text without it being exposed by a property.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      V 1 Reply Last reply
      0
      • D Dave Kreskowiak

        This is actually by design that this happens. An array doesn't implement the databinding interfaces, so the DGV looks at the only property that it can find on each element, Length. You'd have to expose the array in a wrapper class that exposes the text of the string as a property. You cannot bind to the string text without it being exposed by a property.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        V Offline
        V Offline
        V G
        wrote on last edited by
        #3

        Thanks a lot! It works now. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups