I am doing some maintenance on a legacy winforms application.
The project uses form inheritance which makes my job much easier, but there is a strange problem. The setup is as follows:
FormBase : Form
FormBaseList : FormBase
FormClientList : FormBaseList
The problem I have now is with the property WindowsState.
I create a new FormClientList.
FormClientList f = new FormClientList();
f.MdiParent = this;
f.show();
Than I click on the maximize button so it becomes maximized.
Now I have a button (for debug purpose) on FormClientList to show me the value of the property WindowState and it returns maximized, as I expected.
In FormBaseList there is some code that needs to know the value of this property, but here it always returns normal, not maximized. The code is on the doubleclick of a datagridview, which will create another form.
// code in FormBaseList
FormDetail detailForm = new FormDetail();
detailForm.MDIParent = this.MDIParent;
detailForm.Show();
if (this.WindowState == FormWindowState.Normal) // this = the maximized instance of FormClientList
{
// why do I get here when FormClientList is maximized ??
detailForm.Left = this.Left + 20;
detailForm.Top = this.Top + 20;
}
So it seems that the instance of this form has different values for this propertie depending from which class I run my testcode ?
How do I fix this ?