How to resize and move controls?

Posted on 2010-01-01
Last Modified: 2013-12-17
How can I resize and move controls during runt-time using handles like there are in the attached picture ?

How can I do that using or C#?

I know how to move and resize the control without handles. It is not my question. I want to show those handles and, usimg those, the user can move and resize a control as he/she wishes.
Question by:jr_barros_jr
    LVL 12

    Assisted Solution

    Hello, jr_barros_jr,

    You could do this by adding custom controls to the form that represent the grab-handles around the control in question.  

    Override the OnMouseDown method of the grab-handle controls to record the current mouse position and (optionally) define a "tolerance" rectangle.  Then override the OnMouseMove method.  If the mouse button is still down and the mouse has moved outside of the tolerance rectangle invoke the DoDragDrop method.  Finally add code to the Form's DragEnter, DragLeave, DragOver, and DragDrop events to animate the desired operation using the move/resize methods that you are already familiar with.

    I've left out a lot of detail, but that's the gist of it.  It's a fair bit of work, eh.

    LVL 29

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now