Duong Nguyen wrote:
Hello!
How to create and use a FileOpenDialog in Gtk#? Pls help me!
Thanks in advance
Here is how:
// create the dialog
// remember to choose correct FileChooserAction from these self-explanatory values:
// Open, Save, SelectFolder, CreateFolder
FileChooserDialog Fcd = new FileChooserDialog ("Open file", null, FileChooserAction.Open);

// add buttons you wish to see in the dialog
Fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
Fcd.AddButton(Stock.Open, ResponseType.Ok);

// then create a filter for files. For example .gif:
// filter is not necessary if you wish to see all files in the dialog
Fcd.Filter = new FileFilter();
Fcd.Filter.AddPattern("*.gif");

// if you wish to select multiple files set the do the following:
Fcd.SelectMultiple = true;
// In this case read Filenames-property instead of Filename-property

// run the dialog
ResponseType RetVal = (ResponseType)Fcd.Run();

// handle the dialog's exit value
// Read the file name from Fcd.Filename
if (RetVal == ResponseType.Ok) {
// do something
} else {
// do something else
}

// destroy the dialog
Fcd.Destroy();

PS. There is a documentation covering gtk# at http://docs.gotmono.net/.
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to