1,窗口置顶层:
利用form窗口的TopMost属性进行设置。
2,多次点击某个命令时,只打开一个窗口的代码(单一设计模式):
窗体内的代码为:
private static TxtExcelToShpForm instance = null;
public static TxtExcelToShpForm Instance
{
set
{
instance = value;
}
get
{
if (instance == null)
{
new TxtExcelToShpForm();
}
return instance;
}
}
formclosed事件中的代码
private void TxtExcelToShpForm_FormClosed(object sender, FormClosedEventArgs e)
{
instance = null;
}
调用方的代码:
private TxtExcelToShpForm txtExcelToShpForm = TxtExcelToShpForm.Instance;
txtExcelToShpForm.Show();
txtExcelToShpForm.Activate();