OpenFileDialog.FilterIndex : OpenFileDialog « System.Windows.Forms « C# / C Sharp by API






OpenFileDialog.FilterIndex

 

using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;

public class OpenFileDialogEvent{

    static OpenFileDialog openfiledlg1;
    public static void Main()
    {
        openfiledlg1 = new OpenFileDialog();
        openfiledlg1.FileOk += new CancelEventHandler(OnFileOpenOK);
        
        openfiledlg1.Filter = "C# files (*.cs)|*.cs|Bitmap files (*.bmp)|*.bmp";
        openfiledlg1.FilterIndex = 1;
        openfiledlg1.ShowDialog();
    }

    static void OnFileOpenOK(Object sender, CancelEventArgs e)
    {
        MessageBox.Show("You selected the file "+openfiledlg1.FileName);
    }
}

   
  








Related examples in the same category

1.new OpenFileDialog()
2.OpenFileDialog.CheckFileExists
3.OpenFileDialog.FileOk
4.OpenFileDialog.Filter
5.OpenFileDialog.InitialDirectory
6.OpenFileDialog.Multiselect
7.OpenFileDialog.RestoreDirectory
8.OpenFileDialog.ShowDialog()
9.OpenFileDialog.ShowReadOnly
10.OpenFileDialog.Title