【发布时间】:2009-10-05 18:03:11
【问题描述】:
我有一个对话框,显示有关对象的一些信息。我想关闭此对话框以显示相同的对话框,但现在使用对象的兄弟。这是一个复杂的对话框,根据分配的对象加载不同的组件,我不能只更改对另一个对象的引用 我尝试在 Closed 事件中启动新的,但前者并没有从屏幕上消失并一直显示。还尝试了一种在对话框中调用的静态方法,将相同的对话框作为参数传递,因此它关闭对话框“dialog.Close()”并打开一个新对象并显示新对象。但前一个仍然在后面保持开放。 有没有办法做到这一点,关闭第一个窗口并打开第二个窗口?
(这是静态方法,参数传递的窗口在新创建的窗口关闭之前不会关闭)
// From the Dialog try to launch the second one closing this.
private void btnSibling_Click(object sender, EventArgs e)
{
SwitchToSibling(this);
}
private static void SwitchToSibling(SiblingDialog window)
{
try
{
double id = 0;
id = window.SelectedSibling();
if (id != 0)
{
// Get's the same Parent so to the new Dialog
Control owner = window.Owner;
window.Close();
Sibling sibling= Sibling.Get(id);
SiblingDialog.ShowSibling(sibling, false, owner);
}
}
catch (GroupException ex)
{
MessageBox.Show(ex.Message);
}
}
【问题讨论】:
-
所涉及的对话框是模态的还是非模态的?