I am very weak in overriding, overloading etc. so I couldn’t handle this. My problem is this,
I have a frmDialog. It is only used to show the process messages, error messages etc. It takes its text from log, so I don’t need to pass a variable to it. After each process(on other forms), I create this form and call ofrmDialog.ShowDialog(). My problem is that, even when the text is empty, this dialog box opens and shows nothing. So I wanted to override this ShowDialog. ShowDialog returns DialogResult, so I really can’t figure out how to do this.
public override DialogResult ShowDialog(){
if(this.Text != string.Empty){
return base.ShowDialog();
}
else{
//don't do anything
}
}
What do I return when there is else? I really can’t understand this.
Personally I’d recommend putting the ShowDialog in an if statement so that it’s only triggered if the text isn’t empty.
e.g.
That way you can avoid the issues you’re currently having. If you have to return something you can set DialogResult to equal what it needs to be – OK or Cancel for example.
Based on your comments however, I suggest you put this in the else statement of your code: