我正在使用C#,我想做一些类似于当我单击save时弹出的Windows,但是我不知道如何做到这一点。
谢谢你的帮助。对不起,我的英语很差。
发布于 2019-04-01 10:15:01
你可以用Gtk.FileChooserDialog来做
Gtk.FileChooserDialog ClassGtk.FileChooserDialog是一个对话框,适合与“文件/打开”或“文件/另存为”命令一起使用。这个小部件通过在一个Gtk.FileChooserWidget中放置一个Gtk.Dialog来工作。它公开了Gtk.FileChooser接口,因此您可以使用文件选择器对话框中的所有Gtk.FileChooser函数以及用于Gtk.Dialog的函数。
public class MainWindow: Gtk.Window {
protected virtual void OnBtnLoadFileClicked(object sender, System.EventArgs e)
{
Gtk.FileChooserDialog fc=
new Gtk.FileChooserDialog("Choose the file to open",
this,
FileChooserAction.Open,
"Cancel",ResponseType.Cancel,
"Open",ResponseType.Accept);
if (fc.Run() == (int)ResponseType.Accept)
{
System.IO.FileStream file=System.IO.File.OpenRead(fc.Filename);
file.Close();
}
//Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
fc.Destroy();
}在这里阅读更多信息:http://docs.go-mono.com/index.aspx?link=T%3AGtk.FileChooserDialog
https://askubuntu.com/questions/1130305
复制相似问题