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. ListView problem

ListView problem

Scheduled Pinned Locked Moved C#
questionhelp
7 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
    Sebastien Lachance
    wrote on last edited by
    #1

    I have a Object that inherits from ListViewItem. However, when a add this instance to the ListView, there is no text or whatever in it. If I add a SubItem, then the second column is populated but the first still not. How can i display the value on my ListViewItem in the first column ?. Thanks in advance X| Well.. later

    H 1 Reply Last reply
    0
    • S Sebastien Lachance

      I have a Object that inherits from ListViewItem. However, when a add this instance to the ListView, there is no text or whatever in it. If I add a SubItem, then the second column is populated but the first still not. How can i display the value on my ListViewItem in the first column ?. Thanks in advance X| Well.. later

      H Offline
      H Offline
      Hugo Migneron
      wrote on last edited by
      #2

      When you create your ListViewItem object, the string you pass as a parameter is what will be displayed in the first column. For example ListViewItem item = new ListViewItem("Text that will be displayed in the first column"); item.SubItem.add("Text that will be displayed in the second column"); Hope this helps Hugo Migneron

      S 1 Reply Last reply
      0
      • H Hugo Migneron

        When you create your ListViewItem object, the string you pass as a parameter is what will be displayed in the first column. For example ListViewItem item = new ListViewItem("Text that will be displayed in the first column"); item.SubItem.add("Text that will be displayed in the second column"); Hope this helps Hugo Migneron

        S Offline
        S Offline
        Sebastien Lachance
        wrote on last edited by
        #3

        We can pass a ListViewItem to the items.add methods of the ListView, I can't pass a string since a need to put object into the listview. :sigh: Well.. later

        H 1 Reply Last reply
        0
        • S Sebastien Lachance

          We can pass a ListViewItem to the items.add methods of the ListView, I can't pass a string since a need to put object into the listview. :sigh: Well.. later

          H Offline
          H Offline
          Hugo Migneron
          wrote on last edited by
          #4

          I am not sure i understand correctly what you are saying, can you post your code? Hugo Migneron

          S 1 Reply Last reply
          0
          • H Hugo Migneron

            I am not sure i understand correctly what you are saying, can you post your code? Hugo Migneron

            S Offline
            S Offline
            Sebastien Lachance
            wrote on last edited by
            #5

            lstServerExplorer.Items.Clear(); foreach( XmlNode node in xn) { strProvider = node.ChildNodes[0].InnerText.ToString(); strServer = node.ChildNodes[1].InnerText.ToString(); strDatabase = node.ChildNodes[2].InnerText.ToString(); strUser = node.ChildNodes[3].InnerText.ToString(); strPassword = node.ChildNodes[4].InnerText.ToString(); itm = new ConnectionItem(strProvider, strServer, strDatabase, strUser, strPassword); lstServerExplorer.Items.Add(itm); } Where itm is an instance of a class that inherits from ListViewItem. :eek: Well.. later

            H 1 Reply Last reply
            0
            • S Sebastien Lachance

              lstServerExplorer.Items.Clear(); foreach( XmlNode node in xn) { strProvider = node.ChildNodes[0].InnerText.ToString(); strServer = node.ChildNodes[1].InnerText.ToString(); strDatabase = node.ChildNodes[2].InnerText.ToString(); strUser = node.ChildNodes[3].InnerText.ToString(); strPassword = node.ChildNodes[4].InnerText.ToString(); itm = new ConnectionItem(strProvider, strServer, strDatabase, strUser, strPassword); lstServerExplorer.Items.Add(itm); } Where itm is an instance of a class that inherits from ListViewItem. :eek: Well.. later

              H Offline
              H Offline
              Hugo Migneron
              wrote on last edited by
              #6

              I would say you should call the base ListViewItem constructor in the ConnectionItem consctuctor. public ConnectionItem(strProvider, strServer, strDatabase, strUser, strPassword):base([whatever you want to display in your first column]) Hope this helps! Hugo Migneron

              S 1 Reply Last reply
              0
              • H Hugo Migneron

                I would say you should call the base ListViewItem constructor in the ConnectionItem consctuctor. public ConnectionItem(strProvider, strServer, strDatabase, strUser, strPassword):base([whatever you want to display in your first column]) Hope this helps! Hugo Migneron

                S Offline
                S Offline
                Sebastien Lachance
                wrote on last edited by
                #7

                You helped me find the solution. I have used base.Text and it finnally work, thank you so much.;) Well.. later

                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