CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: listbox items

  1. #1
    Join Date
    Aug 2006
    Posts
    20

    listbox items

    when i start my application i want the listbox to take all the folder names in c:\items

    so if c:\items contains the folders d2, d3, d4 etc

    will the listbox have d2, d3, d4 in it when i start my program
    and if i exit my program and create a new folder called s7 in c:\items\ will s7 be in the listbox also when i start my porgram again

    anyone know how to do that?

  2. #2
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Re: listbox items

    Try this :
    Code:
    namespace WindowsApplication5
    
    {
    
    
    
    publicpartialclassForm1 : Form
    
    {
    
    privateDirectoryInfo dirInf;
    
    public Form1()
    
    {
    
    InitializeComponent();
    
    dirInf = newDirectoryInfo(@"c:\items");
    
    foreach (DirectoryInfo dir in dirInf.GetDirectories())
    
    listBox1.Items.Add(dir.Name);
    
     
    
    } 
    
    }
    
    }
    
    

  3. #3
    Join Date
    Aug 2006
    Posts
    20

    Re: listbox items

    it doesnt work :S

    example pls

  4. #4
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Post Re: listbox items

    Open WindowsApplication5.sln then compile . You have the code attached to this reply.
    Last edited by creatorul; August 30th, 2006 at 12:28 PM.

  5. #5
    Join Date
    Aug 2006
    Posts
    20

    Re: listbox items

    Quote Originally Posted by creatorul
    Open WindowsApplication5.sln then compile . You have the code attached to this reply.
    *wrong*
    Last edited by xobx; August 30th, 2006 at 12:07 PM.

  6. #6
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Re: listbox items

    I'm sorry , I patched other code.
    Try this one.
    Attached Files Attached Files
    Last edited by creatorul; August 30th, 2006 at 12:34 PM.

  7. #7
    Join Date
    Aug 2006
    Posts
    20

    Re: listbox items

    now its work perfect! Thaaanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured