I asked this question earlier and thought that he understood it, but it still does not work. Form.Show () slightly moves the position position
So, I have a parent form that opens a bunch of children with show (), and then when necessary, I use the bringToFront () method to display it. The problem is that show () is called a child form, perfectly aligned, but when I use moveToFront, it moves left and down by 1 px, which screws with my borders. I set all child forms of startPosition properties to Manual before show (). I set frm.location = new Point (x, y) when you go back forward. I also tried setting frm.location explication when showing (). It still moves it left and down 1 pixel when I call ToFront (). Is there something with bringToFront () that prevents me from changing the form's location property? Here is my code:
if (myNewForm != null) { myNewForm.MdiParent = this; bool isFormOpen = false; foreach (Form frm in Application.OpenForms) { if (frm.GetType() == myNewForm.GetType()) { frm.WindowState = FormWindowState.Maximized; frm.BringToFront(); frm.Location = new Point(-4, -30); isFormOpen = true; break; } } if (!isFormOpen) { myNewForm.StartPosition = FormStartPosition.Manual; myNewForm.Show(); } }
EDIT: Okay, so Microsoft has an error that allows StartPosition to work only for ShowDialog (), not Show (), but does not fix it: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID= 107589
But my application should support all different forms and just bring them to the forefront when necessary ... so ShowDialog () cannot be used correctly in this case, right? So what are my options? Any?
c # winforms
novacara
source share