I tried setting ".topmost" property to true, but it becomes top most for all the application in windows. I just want the "secondary" form to be topmost on the main form.
Printable View
I tried setting ".topmost" property to true, but it becomes top most for all the application in windows. I just want the "secondary" form to be topmost on the main form.
Try setting the "StartupPosition" property to center parent
you could use .ShowDialog(); so that the form you show doesn't hide behind your other form ( s ) , or .BringToFront(); after showing your form using .Show(); , but the later will allow your new form to hide behind your other forms.
alternatively you could use mdi.
Or you could use ShowDialog(ParentForm);
this will disable (and move back) the parent form until the child form is closed
Do you want this child form to be modal (prevent access to the parent while it's open) like a MessageBox or modeless (allow access to the parent but remain on top) like the Visual Studio Find and Replace dialogue?
If you want it modal then you can simply call ShowDialog. There is no need, or point, to passing the parent form as an argument unless you want to be able to access the parent in code from the child.
If you want it to be modeless then you call Show but you pass the parent form as an argument. This makes the child an owned form of the parent. Owned forms will always appear on top of their owner without prevent access to it. They will also be minimised, restored and closed along with their owner. You can also create an owned form by setting the child form's Owner property or calling the parent form's AddOwnedForm method.