//设置ASN_GR窗体关闭时候,实例为空 void newasnGRForm_Closed(object sender, EventArgs e) { asnGRForm = null; }
private void DG_ASNHeader_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { //得到固定列的某个单元格值 var i = DG_ASNHeader.SelectedItem; var b = i as DataRowView; if (b != null) { Global.strASNNo = b.Row[0].ToString(); Global.strCustomerCode=b.Row[3].ToString(); Global.strCustomerName = b.Row[4].ToString(); } //动态得到某个单元格的值 var cell = DG_ASNHeader.CurrentCell; DataRowView item = cell.Item as DataRowView; if (item != null) { TxtFlowNo.Text = item[cell.Column.DisplayIndex].ToString(); } //双击当前行,则显示收货明细 if (Global.strASNNo != null) //当ASN No不为空时候,才双击显示收货明细窗体 { if (asnGRForm == null || asnGRForm.IsActive) { asnGRForm = new ASN_GR(); asnGRForm.Show(); //Add a event handler to set null our window object when it will be closed asnGRForm.Closed += new EventHandler(newasnGRForm_Closed); } //If the window was created and your window isn't active //we call the method Activate to call the specific window to front else { asnGRForm.Activate(); } } }