Siziing UserControls via a custom ControlDesigner

D

dei

We need to know which edge of a UserControl is being stretched when in
design mode. We've created our own CustomControlDesigner, derived from
ControlDesigner for our UserControl. We can't find a way to determine
which edge of the Designer/Control is being stretched when the control
is being resized in design mode. We want to resize different fields
within the UserControl, based on the edge being dragged.

There does not appear to be a way to get a mouse-down event before the
resize to see which edge the user is being dragged. Any Ideas? Thanks
 
B

Bob Powell [MVP]

You need to have the designer add a handler to the target controls
onsizechanged event and deduce the change.

Ideally, you should not be putting any design time functionality into the
control itself.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
D

dei

How do you deduce which corner or edge of the control was dragged from
the control's OnSizeChanged event? We were trying to hook the
mouse-down event to deduce the edge being dragged.
 
D

dei

How do you deduce which corner or edge of the control was dragged from
the control's OnSizeChanged event? We were trying to hook the
mouse-down event to deduce the edge being dragged.

When you drag the left edge of a control, you get a LocationChanged
event that moves the left edge of the control to your "drop location"
while keeping the size of the control the same. This is followed by a
SizeChanged event that adjusts the width of the control to give it your
new size. How do you differentiate this sequence form a user generated
move of the control followed by a right edge drag of the control?
 
B

Bob Powell [MVP]

In the designer we keep the previous positions of the bits we're interested
in in screen coordinates and do a comparison. This enables us to resize some
control points other than those on the grab-handles.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top