CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    Edinburgh, Scotland
    Posts
    10

    Selecting Directory in Common Dialog Box

    How can I select a directory from the Common Dialog Box. It only allows me to select a file. Am I using the wrong control, or are some of my settings incorrect?



  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Selecting Directory in Common Dialog Box

    use the excellent code pulished by Gilles Roy from
    http://www.codeguru.net/bbs/wt/showp...age=0&Limit=25


  3. #3
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Selecting Directory in Common Dialog Box

    Ooops!

    I was supposed to post that onto the site wasn't I ? I'll get onto it tonight and let you all know where it is.



    Chris Eastwood

    CodeGuru - the website for developers
    http://www.codeguru.com/vb

  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Selecting Directory in Common Dialog Box

    I've added the article/code at :

    http://www.codeguru.com/vb/articles/1864.shtml




    Chris Eastwood

    CodeGuru - the website for developers
    http://www.codeguru.com/vb

  5. #5
    Join Date
    May 1999
    Posts
    7

    Re: Selecting Directory in Common Dialog Box

    Hi,

    If I were you, I'd do the following:

    VB provides 3 special controls named, disklistbox,directorylistbox,filelistbox.You can add those controls to your tool box. They 'll search the drives and directories automatically.Add those 3 controls to your form and You need to connect them by the following code.

    Sub Drive1_change( )
    Dir1.path = Drive1.drive
    End sub

    Sub Dir1_change( )
    File1.path = Dir1.path
    End Sub

    Sub File1_DblClick( )
    On Error GOTO File Error
    if (Right$(Dir1.path,1) = "\") then
    Filename$ = Dir1.path + File1.filename
    else
    Filename$ = Dir1.path + "\" + File1.filename
    endif
    ............
    ............
    File ERROR:
    Msgbox "File ERROR",48,"dialog box" ' Msg box for file error
    resume
    End Sub



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