Hi All,
I'm developing a windows desktop solution using VC# , I deal with my database using Dataset.
My Problem that i'm trying to call a Form to display a confirmation message after every Save, Delete ...., I wanted to make my own Message box, it works well but for one time only, if i tried to call it more than one time it gives me this exception:
<Cannot access a disposed object.
Object name: 'frmMsg'.>
My Code:
Actually I don't even understand why the object has been disposed while the form is still running !!
Need help.
I'm developing a windows desktop solution using VC# , I deal with my database using Dataset.
My Problem that i'm trying to call a Form to display a confirmation message after every Save, Delete ...., I wanted to make my own Message box, it works well but for one time only, if i tried to call it more than one time it gives me this exception:
<Cannot access a disposed object.
Object name: 'frmMsg'.>
My Code:
Code:
public partial class frmOrgHierarchy : Form
{
// Create object from the Message Form
frmMsg objMsg;
public frmOrgHierarchy()
{
InitializeComponent();
objMsg = new frmMsg();
}
private void btnSaveSector_Click(object sender, EventArgs e)
{
try
{
objMsg.Show();
this.Validate();
if (sectorNameTextBox.Text.Equals("") ||
sectorNameTextBox.Text.Equals(null))
{
objMsg.processMessages("برجاء إدخال إسم القطاع", "err");
}
else
{
this.hR_OrgSectorsTableBindingSource.EndEdit();
this.hR_OrgSectorsTableTableAdapter.Update(
this.systemDS.HR_OrgSectorsTable);
hR_OrgSectorsTableBindingNavigator.Enabled = true;
objMsg.processMessages("تم حفظ البيانات !!", "ok");
}
}
catch (Exception ex)
{
//The Exception is being cached here
objMsg.processMessages(ex.Message.ToString(), "err");
}
}
Actually I don't even understand why the object has been disposed while the form is still running !!
Need help.
Comment