Snap Control to grid

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

Hi,

Anyone know how I can have my drag and drop form controls 'snap' to a
grid like in windows desktop?
 
Divide your window (or whatever you are dragging the controls to) up into a
grid based on the size of grid elements and store these in an array (either
two dimensional or use a structure). When the user drops the control onto
your window, determine the x,y nearest in your grid to where the control is
dropped then change the location of the control to that x,y.
 
Back
Top