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. force winforms custom control to be square

force winforms custom control to be square

Scheduled Pinned Locked Moved C#
questioncsharpwinforms
4 Posts 4 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.
  • J Offline
    J Offline
    Jon Hulatt
    wrote on last edited by
    #1

    Hi all, I have a custom winforms control. I want to be able to use anchor/dock type functionality in the form which hosts it, to facilitate dynamic resizing. Only thing is, my control must be square (ie width==height) to render properly. how can i force this to be the case? Thanks Jon

    using System.Beer;

    R realJSOPR B 3 Replies Last reply
    0
    • J Jon Hulatt

      Hi all, I have a custom winforms control. I want to be able to use anchor/dock type functionality in the form which hosts it, to facilitate dynamic resizing. Only thing is, my control must be square (ie width==height) to render properly. how can i force this to be the case? Thanks Jon

      using System.Beer;

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      have you tried ensuring that Width and Height = Math.Min(Width, Height) in the Resize event? Not sure if that'll do what you want but its where I'd start.

      Regards, Rob Philpott.

      1 Reply Last reply
      0
      • J Jon Hulatt

        Hi all, I have a custom winforms control. I want to be able to use anchor/dock type functionality in the form which hosts it, to facilitate dynamic resizing. Only thing is, my control must be square (ie width==height) to render properly. how can i force this to be the case? Thanks Jon

        using System.Beer;

        realJSOPR Online
        realJSOPR Online
        realJSOP
        wrote on last edited by
        #3

        You can't use dock and have the control retain its shape. What you're going to have to do is use anchor, and handle the form's resize event to modify the size and position of the control.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        1 Reply Last reply
        0
        • J Jon Hulatt

          Hi all, I have a custom winforms control. I want to be able to use anchor/dock type functionality in the form which hosts it, to facilitate dynamic resizing. Only thing is, my control must be square (ie width==height) to render properly. how can i force this to be the case? Thanks Jon

          using System.Beer;

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

          You could host your control in a parent control. Dock the parent control, and in its resize handler do something like child.size = min( this.width, this.height ) (and recentre it in the parent if desired)

          Help me! I'm turning into a grapefruit! Buzzwords!

          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