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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. file list and list box problem

file list and list box problem

Scheduled Pinned Locked Moved C#
helpalgorithmsdata-structuresquestion
4 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.
  • D Offline
    D Offline
    djkno3
    wrote on last edited by
    #1

    I have a problem displaying an array of files in a listbox my code for the array is: string[] files = openFileDlg.FileNames; and I looked up the bestway to add multiple files to a listbox and came up with this: lstFiles.Items.AddRange(files); the problem is that my last file when added this way is lost. I also tried setting the datasource to files: lstFiles.DataSource = files; but that did not work either. And forced redraw and reinitilization of the list box evertime my OpenFileDialog was called. My problem I think has to do with improper indexing of files... I say this because I cannot select one file and have it display (it comes up blank) but if I try to open it again it is there. So once my files array first becomes initilized it works. I'm sorry if this question has been asked before but it's late and I have been searching the newsgroups and MSDN and just can't seem to find the answer... Thanks for your help

    D 1 Reply Last reply
    0
    • D djkno3

      I have a problem displaying an array of files in a listbox my code for the array is: string[] files = openFileDlg.FileNames; and I looked up the bestway to add multiple files to a listbox and came up with this: lstFiles.Items.AddRange(files); the problem is that my last file when added this way is lost. I also tried setting the datasource to files: lstFiles.DataSource = files; but that did not work either. And forced redraw and reinitilization of the list box evertime my OpenFileDialog was called. My problem I think has to do with improper indexing of files... I say this because I cannot select one file and have it display (it comes up blank) but if I try to open it again it is there. So once my files array first becomes initilized it works. I'm sorry if this question has been asked before but it's late and I have been searching the newsgroups and MSDN and just can't seem to find the answer... Thanks for your help

      D Offline
      D Offline
      David Stone
      wrote on last edited by
      #2

      Freaky. Just as a matter of course...are you sure you clicked the OK button? It is, after all, late...right? ;)(Not here. It's only 3:30 PM) But that's wierd. 'Cause I've written the same code before and it's always worked for me. :~ [edit]Actually, I just did: fileList.Items.AddRange(fileDialog.FileNames);[/edit]


      You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks -Shog9 teaching Mel Feik how to bookmark I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

      D 1 Reply Last reply
      0
      • D David Stone

        Freaky. Just as a matter of course...are you sure you clicked the OK button? It is, after all, late...right? ;)(Not here. It's only 3:30 PM) But that's wierd. 'Cause I've written the same code before and it's always worked for me. :~ [edit]Actually, I just did: fileList.Items.AddRange(fileDialog.FileNames);[/edit]


        You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks -Shog9 teaching Mel Feik how to bookmark I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

        D Offline
        D Offline
        djkno3
        wrote on last edited by
        #3

        I figured it out... It was about 12:30 am when I posted my question and I will use the lateness of that as an excuse :-D The answer? I have my listbox contained by a panel... The panel was expanded the entire top of the app (eg. under the title bar) so guess what when I set the docking on the listbox to fill... Yep it cut off the top line of my files... Do I ever feel dumb now:rolleyes:

        D 1 Reply Last reply
        0
        • D djkno3

          I figured it out... It was about 12:30 am when I posted my question and I will use the lateness of that as an excuse :-D The answer? I have my listbox contained by a panel... The panel was expanded the entire top of the app (eg. under the title bar) so guess what when I set the docking on the listbox to fill... Yep it cut off the top line of my files... Do I ever feel dumb now:rolleyes:

          D Offline
          D Offline
          David Stone
          wrote on last edited by
          #4

          djkno3 wrote: Do I ever feel dumb now Don't. We all suffer from this type of stuff. BTW, welcome to CP. :-D


          You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks -Shog9 teaching Mel Feik how to bookmark I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

          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