using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public static extern void SetForegroundWindow(IntPtr hWnd);
private void tsbtnDrawOpen_Click(object sender, EventArgs e)
{
//選擇需要打開的文件
//.....
if (openFileDialog.ShowDialog() == DialogResult.Cancel)
{
//修改bug:第二次點擊打開按鈕時需要點擊兩次 事件方可有效 加斷點時可正常打開
//當前窗體獲得焦點
SetForegroundWindow(this.Handle);
return;
}
//......
}