Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 198437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:56:15+00:00 2026-05-11T16:56:15+00:00

Basically when user resizes my application’s window I want application to be same size

  • 0

Basically when user resizes my application’s window I want application to be same size when application is re-opened again.

At first I though of handling SizeChanged event and save Height and Width, but I think there must be easier solution.

Pretty simple problem, but I can not find easy solution to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:56:15+00:00Added an answer on May 11, 2026 at 4:56 pm

    Save the values in the user.config file.

    You’ll need to create the value in the settings file – it should be in the Properties folder. Create five values:

    • Top of type double
    • Left of type double
    • Height of type double
    • Width of type double
    • Maximized of type bool – to hold whether the window is maximized or not. If you want to store more information then a different type or structure will be needed.

    Initialise the first two to 0 and the second two to the default size of your application, and the last one to false.

    Create a Window_OnSourceInitialized event handler and add the following:

    this.Top = Properties.Settings.Default.Top;
    this.Left = Properties.Settings.Default.Left;
    this.Height = Properties.Settings.Default.Height;
    this.Width = Properties.Settings.Default.Width;
    // Very quick and dirty - but it does the job
    if (Properties.Settings.Default.Maximized)
    {
        WindowState = WindowState.Maximized;
    }
    

    NOTE: The set window placement needs to go in the on source initialised event of the window not the constructor, otherwise if you have the window maximised on a second monitor, it will always restart maximised on the primary monitor and you won’t be able to access it.

    Create a Window_Closing event handler and add the following:

    if (WindowState == WindowState.Maximized)
    {
        // Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
        Properties.Settings.Default.Top = RestoreBounds.Top;
        Properties.Settings.Default.Left = RestoreBounds.Left;
        Properties.Settings.Default.Height = RestoreBounds.Height;
        Properties.Settings.Default.Width = RestoreBounds.Width;
        Properties.Settings.Default.Maximized = true;
    }
    else
    {
        Properties.Settings.Default.Top = this.Top;
        Properties.Settings.Default.Left = this.Left;
        Properties.Settings.Default.Height = this.Height;
        Properties.Settings.Default.Width = this.Width;
        Properties.Settings.Default.Maximized = false;
    }
    
    Properties.Settings.Default.Save();
    

    This will fail if the user makes the display area smaller – either by disconnecting a screen or changing the screen resolution – while the application is closed so you should add a check that the desired location and size is still valid before applying the values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I can't think of many occasions where defaults are truly… May 11, 2026 at 7:03 pm
  • Editorial Team
    Editorial Team added an answer For Entity Framework (aka ADO.NET Entity Model) to be there,… May 11, 2026 at 7:03 pm
  • Editorial Team
    Editorial Team added an answer Our team just went through a good few months debating… May 11, 2026 at 7:03 pm

Related Questions

I call my JavaScript function. Why do I sometimes get the error 'myFunction is
I received some justified critical feedback on my last question ( How to gracefully
I have command button added in my asp.net grids. After performing an action using
I am writing a PHP/MySQL program and I would like to know how to
I have a form which is a simple CRUD. I am trying to display

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.