C#Winform关闭当前表格

时间:2012-11-20 16:38:07

标签: 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 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_Ordres? 当我把this.close();由于引用对象为零,它无法工作。

1 个答案:

答案 0 :(得分:0)

声明您在f_Fiche事件的类范围外形成对象Liste_DobleClic,以使其可供该类的其他方法访问。

 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);
        }
}
相关问题