If I understand you, you would like to remember the X,Y position of the windows form.
So when the form is re-opened, it has to appear on the same spot as it was last time, righ?
If so, here is an exmaple how to get the points and insert them into DB:
private void SavingCoordinatesIntoDB()
{
int[] XY = GetFormCoordinates();
using (SqlConnection sqlConn = new SqlConnection("yourConnectionString"))
{
string insertString = "INSERT INTO .... VALUES(@x, @y)";
using (SqlComand cmd = new SqlCommand(insertString, sqlConn))
{
cmd.Parameters.Add("@x", SqlDbType.Int).Value = XY[0];
cmd.Parameters.Add("@y", SqlDbType.Int).Value = XY[1];
sqlConn.Open();
cmd.ExecuteNonQuery();
sqlConn.Close();
//you can put upper line into try, catch statement, to capture the errors (if any occures).
}
}
}
private int[] GetFormCoordinates()
{
int deskWidth = Screen.PrimaryScreen.Bounds.Width;
int deskHeight = Screen.PrimaryScreen.Bounds.Height;
int appWidth = this.Width;
int appHeight = this.Height;
int spX = (deskWidth - appWidth) / 2;
int spY = (deskHeight - appHeight) / 2;
return new int[] { spX, spY };
}
Hope it helps, and this is what you meant. If now, let me know, I`ll try to help you...
bye
Mitja