嗨,我只是想知道为什么会发生这种情况,以及如何阻止这种情况发生?
然后以某种方式最小化表单?
这是一个Windows窗体,中间有一个用户控件。 Windows窗体设置为this.WindowState = System.Windows.Forms.FormWindowState.Maximized
这是我的SaveFileDialog
private void btnExport_Click(object sender, EventArgs e)
{
Microsoft.Win32.SaveFileDialog ofd1 = new Microsoft.Win32.SaveFileDialog();
ofd1.Filter = "Database Files (*.sqlite)|*.db";
ofd1.FileName = "dbwaterworks.sqlite";
// customize file dialog properties here
if (ofd1.ShowDialog() == true)
{
var path = Path.GetFullPath(ofd1.FileName);
var destinationCnx = "Data Source=" + path + "; Version=3;";
using (var source = new SQLiteConnection("Data Source=dbwaterworks.sqlite; Version=3;"))
using (var destination = new SQLiteConnection(destinationCnx))
{
source.Open();
destination.Open();
source.BackupDatabase(destination, "main", "main", -1, null, 0);
}
}
else
{
MessageBox.Show("Canceled");
}
}
答案 0 :(得分:1)
在@HansPassant评论中,将您的主要方法更改为此
[STAThread]
static void Main() {
if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); // Edit as needed
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
不会使其最小化