Click to See Complete Forum and Search --> : Common Dialog Filter
cedx
Dec 6th, 1999, 06:45 AM
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.
MartinLiss
Dec 6th, 1999, 06:54 AM
Something like this should work for you:
MyForm.MyDialog.DefaultExt = "TXT"
MyForm.MyDialog.Filter = "Text Files(*.TXT)|*.TXT"
------------------
Marty
Ruchi
Dec 6th, 1999, 10:36 AM
Place a CommonDialog box on your form.
Open the code window for the Form procedure and add the following 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).]
steviep
Dec 6th, 1999, 07:56 PM
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!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.