Can't override ShowDialog

  • Thread starter Thread starter Martin Hart - Memory Soft, S.L.
  • Start date Start date
M

Martin Hart - Memory Soft, S.L.

Hi:

I have a set of derived forms that I wish to implement an 'Execute' method
to launch these forms, but I also wish to hide the 2 inbuilt ShowDialog
methods so these can't be called unwittingly.

I have tried:

private new DialogResult ShowDialog() { }
private new DialogResult ShowDialog(IWin32Window aParent) { }

but these are completely ignored and the 2 methods are still visible and
usable.

How can I hide these?

TIA,
Martin.
 
Because I'm trying to hide them so they can't be called externally
accidentally.

Regards,
Martin.
 
In your case, I think you should have the Execute method as a static method.
In your class, hold the object of your form privately, so that the outside
world won't be able to create the form object 'accidentally'
If the world can create a System.Windows.Form, then it will be able to call
ShowDialog.

or you can define your methods publically and call do the checks and call
your execute method

public new DialogResult ShowDialog()
{
return this.Execute();
}

I assume Execute() method returns a DialogResult

HTH,

--Saurabh
 
Back
Top