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