Results 1 to 4 of 4

Thread: Common Dialog Filter

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Posts
    80

    Post

    Hi,

    How do I avoid showing all types of files in the Common Dialog control.

    I tried setting the Filter property to "*.txt" at design time but all files in the directory will show up regardless of extensions.

    Am I specifying the property wrong or is there another way to do it?

    Thanks in advance.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Something like this should work for you:
    Code:
        MyForm.MyDialog.DefaultExt = "TXT"
        MyForm.MyDialog.Filter = "Text Files(*.TXT)|*.TXT"

    ------------------
    Marty

  3. #3
    Member
    Join Date
    Dec 1999
    Posts
    37

    Post

    Place a CommonDialog box on your form.
    Open the code window for the Form procedure and add the following code.

    Code:
    Private Sub Form_Load()
    
    'Setup common dialog box for open file type. Add filter
        CommonDialog1.Filter = "Text Documents(*.txt)|*.txt"
        CommonDialog1.DialogTitle = "Select a File to Load"
        CommonDialog1.Action = 1   'Opem File type
    End Sub
    Hope this helps.

    Ruchi

    [This message has been edited by Ruchi (edited 12-06-1999).]

  4. #4
    Member
    Join Date
    Sep 1999
    Location
    UK
    Posts
    45

    Post

    Stick a common dialog control on your form together with a command button - double click on the button to get the code then enter:

    --
    Private Sub Command1_Click()

    With CommonDialog1
    .Filter = "Wav Files|*.wav"
    If Err.Number = cdlCancel Then Exit Sub
    MMControl1.FileName = .FileName
    End With

    End Sub
    -- Hope this helps!

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