Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to get location coordinates for a DataGridViewTextBoxCell

$
0
0

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.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>