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. C#
  4. Keeping a panel proportional

Keeping a panel proportional

Scheduled Pinned Locked Moved C#
toolshelpquestionworkspace
1 Posts 1 Posters 0 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.
  • S Offline
    S Offline
    sinosoidal
    wrote on last edited by
    #1

    Hi, I want to implement a preview area which i want it to have a proportional size to the display resolution. I have a workspace which is a form which is docked fill to my main window. This is my panel size adjust function: private void AdjustLayoutEditorSizeToDisplay(int width, int height) { int panelHeight; Console.WriteLine("Display size: " + width + " x " + height); Console.WriteLine("tpLayout size: " + this.Size.Width + "x" + this.Size.Height); Console.WriteLine("regionPanel initial size: " + regionsPanel.Size.Width + "x" + regionsPanel.Size.Height); int percent = Utility.PixelsToPercent(this.Size.Width, width); Console.WriteLine("The provided width is " + percent + "% of the maximum percentage."); if (percent > 100) { int diff = percent - 100; panelHeight = Utility.PercentToPixels(height, 100 - diff); Console.WriteLine("The height calculated based on the percentage is " + panelHeight + "."); } else { panelHeight = Utility.PercentToPixels(height, percent); Console.WriteLine("The height calculated based on the percentage is " + panelHeight + "."); } regionsPanel.Size = new Size(this.Size.Width, panelHeight); Console.WriteLine("regionPanel final size: " + regionsPanel.Size.Width + "x" + regionsPanel.Size.Height); } I provide the resolution and suposly it will make the panel adjust its width to the workspace width and the height propotional to that. But i found a problem, when docked, a panel seems to keep its original Size property and so it will not give me a correct proportion and it will not adjust its width to the workspace width. WEll.. can somebody tell me if there is a turn around for this? Thx, Nuno

    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