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. C#
  4. A silly listview question

A silly listview question

Scheduled Pinned Locked Moved C#
databasedata-structuresquestion
2 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.
  • S Offline
    S Offline
    sameerhanda
    wrote on last edited by
    #1

    Ok, I am trying to retrieve a list of names from the database and based upon the number of rows retrieved from the DB, I am trying to do the following: 1. Instantiate a array of command buttons. 2. Add those command buttons to the list view. I am assuming step 2 is possible since the item property is a collection of objects, I can add anything I want to add to it. Well it works fine except instead of actual command buttons, I am seeing the following , "System.windows.forms.Buttons, Text="rwqr"" What am i doing wrong.

    L 1 Reply Last reply
    0
    • S sameerhanda

      Ok, I am trying to retrieve a list of names from the database and based upon the number of rows retrieved from the DB, I am trying to do the following: 1. Instantiate a array of command buttons. 2. Add those command buttons to the list view. I am assuming step 2 is possible since the item property is a collection of objects, I can add anything I want to add to it. Well it works fine except instead of actual command buttons, I am seeing the following , "System.windows.forms.Buttons, Text="rwqr"" What am i doing wrong.

      L Offline
      L Offline
      LobsterDK
      wrote on last edited by
      #2

      What you are trying to do is not directly possible with the listview provided with .NET. The items collection is a collection of data associated with each element in the list, not a collection of controls to be displayed within the list. By default, if no string is supplied when adding items to the collection the objects ToString method is used to get the string to display. This is why you are getting the output you are getting. There are articles here on Code Project that show listview implementations that are capable of docking other controls within the listview. Note that it's not something you will be able to do with a trivial amount of code (though not an unobtainable goal either).

      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