When I do this from inside my add_Click() function , I get an error:
Cannot access a disposed object.
Object name: 'ConflictList'.
The error is shown at the semicolon after I call ShowDialog(); i.e.
ConflictList dlg = new ConflictList();
dlg.ShowDialog();<- Right here
Any ideas?
Phil
"Nicholas Paldino [.NET/C# MVP]" wrote:
Phil,
You can just call the Close method on your form. You are specifying the
value of the DialogResult property beforehand, and this is what will be
returned from the call to ShowModal.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Phil" <ph****@sbcglobal.netwrote in message
news:66**********************************@microsof t.com...
I have a modal form (ShowDialog()) that I may want to close when a user
clicks a button. I already have an OK and Cancel button, so I can't use
those options, but I want it to function just like an OK button press.
See
Example:
private void add_Click(object sender, EventArgs e)
{
// Do some work...
if (itemcnt == 0)
{
this.DialogResult = DialogResult.Cancel;
// Close current form and return.
}
}