[英]C# Winform close current form
i have a current form that contain a grid.我有一个包含网格的当前表单。 i create a function that open a new form when i double clic the row of this grid.我创建了一个函数,当我双击该网格的行时会打开一个新表单。
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);
}
}
how can i close Liste_Ordres ?我怎样才能关闭 Liste_Ordres ? when i put this.close();当我把 this.close(); it cannot work because of reference object is zero.它无法工作,因为参考对象为零。
Declare you form object f_Fiche
on class scope out side the Liste_DobleClic
event to make it accessible to other method of the class.声明您在Liste_DobleClic
事件f_Fiche
的类范围内形成对象f_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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.