To re-size Controls at run-time you are going to need to implement three EventHandlers for the Control (shown here wired-up in the Form Load EventHandler):
private void Form1_Load(object sender, EventArgs e)
{
YourControl.MouseDown += YourControl_MouseDown;
YourControl.MouseUp += YourControl_MouseUp;
YourControl.MouseMove += YourControl_MouseMove;
}
private bool IsMouseUp = true;
private Point MouseDownPoint;
private Size ControlSize;
private void YourControl_MouseDown(object sender, MouseEventArgs e)
{
IsMouseUp = false;
ControlSize = YourControl.Size;
MouseDownPoint = e.Location;
}
private void YourControl_MouseUp(object sender, MouseEventArgs e)
{
IsMouseUp = true;
}
private void YourControl_MouseMove(object sender, MouseEventArgs e)
{
if (IsMouseUp) return;
YourControl.Width = ControlSize.Width + e.X - MouseDownPoint.X;
YourControl.Height = ControlSize.Height + e.Y - MouseDownPoint.Y;
}
This is, of course, pretty simple re-sizing: we're keeping the left-top corner of the Control "pinned" and manipulating its width and height based on relative offsets calculated from the initial and current position of the mouse during the MouseMove Event.
And, we're not doing any checking for things like making the Control so large part of it goes off-screen. You can, of course, limit the re-sizing of the Control by setting the Minimum- / Maximum- Size Properties at design time, and I strongly suggest you do that so your users will not accidentally hide the Control !
It gets much more interesting when you want to detect the direction of re-size and actually move the Control as well as re-size it. That's ... another story.