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

Thread: File Dialog Box

  1. #1
    Join Date
    Jan 2001
    Posts
    27

    File Dialog Box

    Hello! I would like the user to be able to click a button and have a select file dialog box pop up with a directory already specified and a file extention locked in. I know this is possible and easy, just cant remember the way to call it.

    Thanks!



  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: File Dialog Box

    I think what you need is a commondialog control.

    you can set the file to be selected using filter property, e.g. if you only want to display text file

    filter = text (*.txt)

    you can call the method ShowOpen to pop up the dialog box.

    hope this help.

    cksiow
    http://vblib.virtualave.net - share our codes



  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: File Dialog Box

    Place a commondialog control on your form, and name it cdbOpen

    Then in code,


    on error goto ErrHndlr
    with cdbOpen
    .CancelError=true
    .Dialogtitle="Open a file"
    .filter="Text Files (*.txt)|*.txt|All Files|*.*"
    .initdir="c:\my documents"
    .showopen
    end with
    'Do your work here
    Exit sub
    ErrHndlr:
    'Cancel Was pressed
    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