C#Winform关闭当前窗体
我有一个包含网格的当前表单。我创建了一个函数,在双击该网格的行时打开一个新窗体C#Winform关闭当前窗体,c#,winforms,C#,Winforms,我有一个包含网格的当前表单。我创建了一个函数,在双击该网格的行时打开一个新窗体 public partial class Liste_Ordres : DevExpress.XtraEditors.XtraForm { public string Id = ""; LeOrdre_BL oOrdre_BL = new LeOrdre_BL(); LeOrdreStatut_Entite_BL oStatutOrdre_BL = new L
public partial class Liste_Ordres : DevExpress.XtraEditors.XtraForm
{
public string Id = "";
LeOrdre_BL oOrdre_BL = new LeOrdre_BL();
LeOrdreStatut_Entite_BL oStatutOrdre_BL = new LeOrdreStatut_Entite_BL();
public Liste_Ordres()
{
....
}
private void Liste_DobleClic(object sender, EventArgs e)
{
try
{
Program.OrderId = gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString();
Program.StatusOrdre = Convert.ToInt32(gridView_Liste_Ordres.GetFocusedRowCellValue("STATUT_ORDRE"));
if (gridView_Liste_Ordres.GetFocusedRowCellValue("MODAL_MODE").ToString() == "A")
Fiche_Ordre f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
f_Fiche.MdiParent = this.MdiParent;
f_Fiche.Show();
}
catch (Exception excThrown)
{
MessageBox.Show(excThrown.Message);
}
}
如何关闭列表?
当我把这个放进去的时候。关闭();它无法工作,因为引用对象为零。在类作用域的
Liste\u DobleClic
事件外声明您的窗体对象f\u Fiche
,以使类的其他方法可以访问它
Fiche_Ordre f_Fiche = null;
private void Liste_DobleClic(object sender, EventArgs e)
{
try
{
Program.OrderId = gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString();
Program.StatusOrdre = Convert.ToInt32(gridView_Liste_Ordres.GetFocusedRowCellValue("STATUT_ORDRE"));
if (gridView_Liste_Ordres.GetFocusedRowCellValue("MODAL_MODE").ToString() == "A")
f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
f_Fiche.MdiParent = this.MdiParent;
f_Fiche.Show();
}
catch (Exception excThrown)
{
MessageBox.Show(excThrown.Message);
}
}
在这一行之前f_Fiche=new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue(“NO_Ordre”).ToString());当您尝试此.Close()时,会出现什么错误?