I need some clarification, please anyone help me thanks in advance.
I have a panel with multiple controls such us label, datagridview, text boxes and buttons. I added 'n' number of panels dynamically into the TableLayoutPanel
. I need to transfer records from one datagridview to another datagridview, which one residing in corresponding TableLayoutPanel
. My problem is, how can I identify the data send to which data grid. Is there any possible to get column index by clicking a child controls.
Place dummy image objects in each cell. And try this on Drop event of TableLayoutPanel
private void tableLayoutPanel1_DragDrop(object sender, DragEventArgs e)
{
Point p = tableLayoutPanel1.PointToClient(new Point(e.X, e.Y));
Control c = tableLayoutPanel1.GetChildAtPoint(p);
int row = tableLayoutPanel1.GetRow(c);
int col = tableLayoutPanel1.GetColumn(c);
}
If you want to know the index of a say button which is being clicked in Gridview...
1- while creating them dynamically store the row-col info in Tag eg "1-2" and then use it later
2- You can iterate to find row-col to see where this matches.
If you have ref of the DataGridViewCell
Then it's simple:
DataGridViewCell.RowIndex DataGridViewCell.ColumnIndex
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.