savefiledialog.opendialog() 最小化表格
savefiledialog.opendialog() minimizes form
嗨,我只想知道为什么会这样,我怎样才能阻止它发生?
这是我点击导出数据之前的样子
然后它以某种方式最小化表单?
这是一个 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");
}
}
来自@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();
不会使其最小化
嗨,我只想知道为什么会这样,我怎样才能阻止它发生?
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");
}
}
来自@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();
不会使其最小化