OpenFileDialog Event: FileOk : OpenFileDialog « GUI Windows Forms « C# / CSharp Tutorial






OpenFileDialog Event: FileOk
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);
    }
}








23.45.OpenFileDialog
23.45.1.Simple Open file dialogSimple Open file dialog
23.45.2.OpenFileDialog Event: FileOkOpenFileDialog Event: FileOk
23.45.3.OpenFileDialog: browsing for a fileOpenFileDialog: browsing for a file
23.45.4.OpenFileDialog: browsing for a set of filesOpenFileDialog: browsing for a set of files
23.45.5.OpenFileDialog: filer, initial directory