-1

グリッドを含む現在のフォームがあります。このグリッドの行をダブルクリックすると新しいフォームを開く関数を作成します。

 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(); を入れたとき 参照オブジェクトがゼロであるため、機能しません。

4

1 に答える 1

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);
        }
}
于 2012-11-20T16:40:24.840 に答える