I have a ListView that I want to place just under a DataGridViewTextBoxCell when the cell is entered. My DataGridView with the DataGridViewTextBoxCell resides in a panel in a splitContainer. The code below returns coordiantes of x = 0 and y = 3 which are nowhere near the actual location of the cell. How can I find the true coordinates so that I can correctly place the ListView?
private void dgvSandbox_CellEnter(object sender, DataGridViewCellEventArgs e) { DataGridView dgv = (DataGridView)sender; DataGridViewTextBoxCell tbCell = (DataGridViewTextBoxCell)dgv[e.ColumnIndex, e.RowIndex]; int tbCellX = tbCell.ContentBounds.Location.X; int tbCellY = tbCell.ContentBounds.Location.Y; myListView.Width = 100; myListView.Height = 100; myListView.Location = new Point(tbCellX, tbCellY + 22); myListView.View = View.Details; myListView.Visible = true; myListView.BringToFront(); }
Rob E.