hi all
I have 4 buttons and a tablelayoutpanel with 5 cells
I want the buttons to be able to drag and drop in any of the cells
Printable View
hi all
I have 4 buttons and a tablelayoutpanel with 5 cells
I want the buttons to be able to drag and drop in any of the cells
Drag and drop is a very standard mechanism and is performed in essentially the same way no matter the data being dragged. You should search MSDN to get the basics. Once you understand the principles involved then you'll understand what I'm about to say and where it fits in.
Handle the MouseDown event of the Buttons and pass the Button itself to DoDragDrop as the data. You then handle the DragDrop event of the TLP to get a reference to the Button that you need to drop. You can then calculate the column and row position of the mouse cursor and call the grid's SetCellPosition method to move the Button to that cell.