private void EditForm_FormClosing(object sender, FormClosingEventArgs e) { if (context == null) { return; } if (txtMemoText.Text.Length > 0) { btnSave.PerformClick(); //store current remark } context.Save(); context = null; }