I'm not sure if this is allowed but I have a main form that calls another form with ShowDialog which attempts to call another form the same.
So, for example:
form1 -> form2.showdialog -> form3.showdialog
I am getting an error at the showdialog of form3:
var ssscu = new SSS.SssTwainSimple.MainForm();
ssscu.ShowDialog();
This is the error:
{"Form showDialog tried to set an ineligible form as its owner. Forms cannot own themselves or their owners.\r\nParameter name: owner"}
I'm not sure I understand what the problem is, am I not allowed to call a showdialog from a form that is a dialog?
Thanks, Eroc
am I not allowed to call a showdialog from a form that is a dialog?
You certainly are allowed, this ought to work.
But I do think it is strange that you create a dialog-form called MainForm.
I expect it is something caused by other stuff happening in events. What does mainForm do in it's constructor/Load-event ?
It is a very unusual exception. The form already has an owner when it got created by the constructor. You didn't use the ShowDialog(owner) override so Windows Forms has to find an owner for itself. It finds the exact same form back. That's technically possible, but you'd have to write some fairly odd code. To diagnose this, add this code to the form:
protected override void OnHandleCreated(EventArgs e) {
base.OnHandleCreated(e);
}
And set a breakpoint on it. If my guess is correct, this will break before the ShowDialog call. Look at the call stack to see what statement is getting that window created.
Try replace .ShowDialog();
with .ShowDialog(this);
Edit: I have not tried myself, but this is where I would start looking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With