Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want my controls on a form to be resizable and user can move the mouse pointer to the edges of the controls to start resizing their size.
Can I do that? If I can, could you please suggest me some solution?
Thank you so much!
Posted
Updated 22-Aug-11 19:39pm
v2

you can use resizable control available in in AJAX control toolkit. Please refer the link below.
http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/ResizableControl/ResizableControl.aspx[^]
 
Share this answer
 
Comments
Member 7797800 23-Aug-11 2:32am    
please refer the link below
http://www.codeproject.com/KB/cs/ResizeControlsRuntime.aspx
[no name] 23-Aug-11 2:38am    
I'm sorry but I wanna ask more if I can use that toolkit to build a windows form application? That's for I think the toolkit you suggested seems to be used for only web applications.
Thank you so much!
To move, or re-size, controls in WinForms, you are going to need to write event handlers for each control's MouseDown, MouseUp, and MouseMove events.

In the MouseDown event set a boolean flag to 'true, indicating the mouse is down, and record the position of the MouseDown; in the MouseUp event set that flag to 'false.

In the MouseMove event, test the boolean flag for the mouse being down, and, if it is: calculate a deltax and deltay vector based on the difference between initial MouseDown and the current Mouse position in the MouseMove event.

And then, for re-size, it gets interesting: if you are dragging in a way that the origin of the control can stay the same, that's a simpler case: you're just going to add your deltax to the control's width, and the deltay to the controls height.

Suggest you start by implementing the simple case where the control's origin can remain fixed, and then move on to thinking about what you need to do to handle the resize cases when the control's origin must move.

best, Bill
 
Share this answer
 
v3
Comments
[no name] 25-Aug-11 1:59am    
Thank you! Your solution is actually the normal and standard one.
I am wondering if we have another one to do it easier. Anyway, thank you so much!
To some extend, you could get away using SplitContainer. It enables user to resize hosted controls horizontally XOR vertically. You can combine several of these.
 
Share this answer
 
Comments
[no name] 25-Aug-11 2:01am    
Thank you! It's a pity that there's not any example here! Could you me some link?
lukeer 25-Aug-11 3:20am    
I don't have a link at hand. Normally, I would use Visual Studio's designer this way:

1. Drop a SplitContainer on your form.
2. Set the Orientation property to Horizontal or Vertical
3. Place one control on each side of the splitter
(Each control can again be a SplitContainer).

Further, brows the control's properties to customize it. I'm sure MSDN and the well-known internet search engines will provide more detailed information upon request.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900