Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Windows Form Application Size Issue

Windows Form Application Size Issue

Scheduled Pinned Locked Moved Windows Forms
designhelptutorialquestionannouncement
4 Posts 4 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    ukraju
    wrote on last edited by
    #1

    Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.

    S B B 3 Replies Last reply
    0
    • U ukraju

      Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      How is it not showing in the correct way? what is the actual issue. All I can see is that you are setting 2 panels and the form to the same size at runtime

      Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

      1 Reply Last reply
      0
      • U ukraju

        Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        InitializeComponent(); should be the first statement after the constructor. Do you know what happens in that function? A lot of values, among them positions and sizes, are set. I'd rather use a this.WindowState = FormWindowState.Maximized; in the Form_Shown event. If you want to re-order the elements, you can additionally subscribe to a Resize event, and do that there.

        1 Reply Last reply
        0
        • U ukraju

          Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #4

          I believe Bernard Hiller gave you the correct answer (I voted his answer #5, naturally): move the call to InitializeComponent() to before your Form and Panel adjustment code. An edge-case hypothesis could be: the monitors have different aspect ratios, but I doubt that. best, Bill

          "Everything we call real is made of things that cannot be regarded as real." Niels Bohr

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups