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. Windows API
  4. updating a list box

updating a list box

Scheduled Pinned Locked Moved Windows API
helpquestionannouncement
5 Posts 3 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.
  • L Offline
    L Offline
    lovneet
    wrote on last edited by
    #1

    hi! as a part of my code i need to read a file and then update the contents in a list box. the file to b read has say 6 items, each in a new line. and i want them to appear the same way in the list box, ie, all the 6 items should appear in a new line each. can someone help me with this? any help will b greatly appreciated! regards lovy.

    S 1 Reply Last reply
    0
    • L lovneet

      hi! as a part of my code i need to read a file and then update the contents in a list box. the file to b read has say 6 items, each in a new line. and i want them to appear the same way in the list box, ie, all the 6 items should appear in a new line each. can someone help me with this? any help will b greatly appreciated! regards lovy.

      S Offline
      S Offline
      Stu Richardson
      wrote on last edited by
      #2

      I am not sure which language you are looking to find the answer for here so i will give you the best general answer I can. 1. There are thousands of articles online so i would search google for a "how to" on reading from files. Like so: http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx[^] 2. Then user either the listbox.Items.AddRange or listbox.Items.Add methods to add the items you have read from the file into the listbox. I would personally use the AddRange method. I hope this helps in some way. Also I would move this message into a more relevant forum. This way you will have more chance of getting help in the language you want.

      L 1 Reply Last reply
      0
      • S Stu Richardson

        I am not sure which language you are looking to find the answer for here so i will give you the best general answer I can. 1. There are thousands of articles online so i would search google for a "how to" on reading from files. Like so: http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx[^] 2. Then user either the listbox.Items.AddRange or listbox.Items.Add methods to add the items you have read from the file into the listbox. I would personally use the AddRange method. I hope this helps in some way. Also I would move this message into a more relevant forum. This way you will have more chance of getting help in the language you want.

        L Offline
        L Offline
        lovneet
        wrote on last edited by
        #3

        thanks man. well m using VC++ and apparently haven't been able to find any method that does so. again the problem is that I have to read a file and then update the listbox so AddString doesnt work. Reading line wise from a file is tedious and cumbersome. It will be great if you can help me out. thanks regards lovy

        S realJSOPR 2 Replies Last reply
        0
        • L lovneet

          thanks man. well m using VC++ and apparently haven't been able to find any method that does so. again the problem is that I have to read a file and then update the listbox so AddString doesnt work. Reading line wise from a file is tedious and cumbersome. It will be great if you can help me out. thanks regards lovy

          S Offline
          S Offline
          Stu Richardson
          wrote on last edited by
          #4

          I know very little about VC++ - I would post your question in the specific language forum. Sorry I cant be of much further help.

          1 Reply Last reply
          0
          • L lovneet

            thanks man. well m using VC++ and apparently haven't been able to find any method that does so. again the problem is that I have to read a file and then update the listbox so AddString doesnt work. Reading line wise from a file is tedious and cumbersome. It will be great if you can help me out. thanks regards lovy

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            Reading a text file is trivial, and to change the string in a listbox, I always use DeleteString and AddString. In fact, if I were getting contents from a text file, I'd probably calle ResetContent, and then AddString to put the text from the file in there. Don't forget to call SetRedraw(FALSE) before doing that so the listbox doesn't cause your users to have a seizure when it flashes and blinks at them during the update. Of course, as already mentioned, you would get better help if you actually posted this question in the appropriate programming forum.

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            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