日期:2014-05-20  浏览次数:20721 次

请问:如何得到DataGridView中某一个Column的位置坐标值?
如题。

DataGridViewColumn不是从Control继承来的,也没法强制转换,所以不能像TextBox1.Left这样取到它的坐标...

dg.Columns[ID].Left出现编译错误,哪位知道正确的方法,谢谢!

------解决方案--------------------
首先取出datagrid的坐标,然后再取列的坐标.如果一开始找列的坐标是找不到的
------解决方案--------------------
Rectangle rect = dataGridView1.GetCellDisplayRectangle(
dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex,true);
------解决方案--------------------
求某一Cell在窗体中的座标
假如求第2列
grid1.Location.X + grid.RowHeadersWidth + grid.Columns[0].Width

列怎么能求坐标列?列是集合啊
------解决方案--------------------
只有用 javascript 处理,C# 没办法