TableLayoutPanel and Getting a Cell by Mouse position
-
Hi All, I have a TableLayoutPanel on a form and I want to let the user drag and drop objects on to it. I need to find out on which cell the dragged object has been dropped. is there any way to do it? Thanks a lot
Aref
-
Hi All, I have a TableLayoutPanel on a form and I want to let the user drag and drop objects on to it. I need to find out on which cell the dragged object has been dropped. is there any way to do it? Thanks a lot
Aref
Hi there, What I would do is to create inside each cell a full-docked control, like an empty label, then on the TableLayoutPanel DragDrop event I'd get the cell by the position of the control: private void tableLayoutPanel1_DragDrop(object sender, DragEventArgs e) { Point p = tableLayoutPanel1.PointToClient(new Point(e.X, e.Y)); Control c = tableLayoutPanel1.GetChildAtPoint(p); TableLayoutPanelCellPosition cellPos = tableLayoutPanel1.GetCellPosition(c); } Try it, it's working. The cell that gets the drop is reprisented by cellPos.Row and cellPos.Column Hope that help. Danny
-
Hi there, What I would do is to create inside each cell a full-docked control, like an empty label, then on the TableLayoutPanel DragDrop event I'd get the cell by the position of the control: private void tableLayoutPanel1_DragDrop(object sender, DragEventArgs e) { Point p = tableLayoutPanel1.PointToClient(new Point(e.X, e.Y)); Control c = tableLayoutPanel1.GetChildAtPoint(p); TableLayoutPanelCellPosition cellPos = tableLayoutPanel1.GetCellPosition(c); } Try it, it's working. The cell that gets the drop is reprisented by cellPos.Row and cellPos.Column Hope that help. Danny
Hello danny, What is the relevance of creating a full docked control as you have explained. It will be great if you could spare some time to explain. Thanks, CPM
-
Hello danny, What is the relevance of creating a full docked control as you have explained. It will be great if you could spare some time to explain. Thanks, CPM