如何在DataGridView中获取当前的单元格位置x和y? [英] How do I to get the current cell position x and y in a DataGridView?
本文介绍了如何在DataGridView中获取当前的单元格位置x和y?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不想要当前的单元格或当前列,我想要的位置,以便我可以设置我的日期表单的位置。
这是我正在使用的,但它不工作:
int po_X = paygrid.GetCellDisplayRectangle e.ColumnIndex,e.RowIndex,false).Left + paygrid.Left;
int po_Y = paygrid.GetCellDisplayRectangle(e.ColumnIndex,e.RowIndex,false).Bottom + paygrid.Top;
form_date.Location = new System.Drawing.Point(po_X,po_Y);
解决方案
可以使用paygrid.PointToScreen()方法。 / p>
form_date.Location = paygrid.PointToScreen(
paygrid.GetCellDisplayRectangle(e.ColumnIndex,e.RowIndex,false)。位置);
I have a Windows form with a calendar which is hidden. I want to show the form right under the current cell of a DataGridView. The position changes according to the position of current cell.
I don't want the current cell or current column, I want the position so that I can set the location of my date forms.
Here is what I am using but its not working:
int po_X = paygrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Left+paygrid.Left;
int po_Y = paygrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Bottom+paygrid.Top;
form_date.Location = new System.Drawing.Point(po_X, po_Y);
解决方案
You can use paygrid.PointToScreen() method.
form_date.Location = paygrid.PointToScreen(
paygrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location);
这篇关于如何在DataGridView中获取当前的单元格位置x和y?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文