This is a WinForm application question in .net. It is about MDI form.
I have an MDI form (ParentForm), in which I can create many instance forms of ChildForm. I create two ChildForm, named, cf1 and cf2 one by one. So, cf1 will have a Z index lower than cf2 and cf2 will be on top of cf1.
Then I switch to some other form, meaning ParentForm loses its focus in Windows. Then I switch back to ParentForm. When this happens, ParentForm always automatically put cf1 on top of cf2.
This happens as well if I have three instances of ChildForm. ParentForm always puts the instance created first to top when I switch back to ParentForm.
Now the interesting thing is, it happens only for ChildForm of course (if it is the case for any child form, that will be a bug of .net). I think there is something wrong in my ChildForm that triggers this but I have no idea what is that. There is no onActive event for both ChildForm and ParentForm.
The instances of ChildForm are created directly in ParentForm, sample code is:
ParentForm_CreateChildForm(){ var cf = new ChildForm(); cf.MdiParent = this; cf.Show(); }
Anyone came across with this before is welcomed to give me some hints on what could possibliy goes wrong.
Thank you very much.