本文介绍了如何在C#中将Windows窗体带到前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在我的应用程序 时,用户点击标签打开表单,表单打开在背景中。我的意思是它没有出现在前面,但是而是放在任务栏上。一旦用户取消该表格实例并再次点击标签,表单将在前景中打开。以下部分代码执行特定的工作。 if (DataFormDlg.Instance.InvokeRequired) { DataFormDlg.Instance.BeginInvoke( new ShowDataFormDelegate(ShowDataForm),pageId,timeout); return ; } DataFormDlg.Instance.CurrentPageId = pageId; DataFormDlg.Instance.Timeout = timeout; if (!DataFormDlg.Instance.Visible) DataFormDlg.Instance.ShowDialog(); else DataFormDlg.Instance.Focus(); 这里的DataFormDlg 从窗体中派生。 我尝试过: 我听说BringToFront()和Activate()可能会有所帮助但不确定如何使用它们。解决方案 In my application when the user clicks on a label to open a form the form opens in the background.I mean it does not come to the front but is rather placed on taskbar. once the user cancels that instance of form and again clicks on the label,the form opens in foreground.Following portion of code does the specific work.if (DataFormDlg.Instance.InvokeRequired) { DataFormDlg.Instance.BeginInvoke( new ShowDataFormDelegate(ShowDataForm), pageId, timeout); return; } DataFormDlg.Instance.CurrentPageId = pageId; DataFormDlg.Instance.Timeout = timeout; if (!DataFormDlg.Instance.Visible) DataFormDlg.Instance.ShowDialog(); else DataFormDlg.Instance.Focus();Here the DataFormDlg is derived from windows form.What I have tried:I have heard that BringToFront() and Activate() might help but not sure on how to use them. 解决方案 这篇关于如何在C#中将Windows窗体带到前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-25 03:03