Setting the Screen Location of Windows Forms

  • Thread starter Thread starter G Uljee
  • Start date Start date
G

G Uljee

Hi all,



I've some difficulties with the screen/form locations.

When I fist set my location of the form and then the execute the show
command the form is located at "WindowsDefaultLocation".

Based on that I've created the following procedure:



/// <summary>

/// Set the specified window's size and location.

/// The size is only adjusted if both the width and
height are > 0

/// </summary>

public void Set(System.Windows.Forms.Form form)

{

if(form != null)

{

if(m_visible)

{

form.Show();

form.Refresh();

}

if(m_width>0 && m_height>0)

form.Size = new
Size(m_width, m_height);

form.Location = new
Point(m_X, m_Y);

form.Refresh();

}

}



But now you're able to see that the location will be changed.

What can I do about this?



Thanks in advance,

Gaby
 
Hi,

I may not getting you right, but you can change the FormStartPosition
property value to "Manual" and then set the values of the Size and Location
properties in code or in the designer. Then, when you invoke the Show()
method, the form will be displayed in the specified position and will have
the requested bounds.
 
Back
Top