日期:2014-05-18  浏览次数:20954 次

如何获得datagridview单元格中心的坐标
如何获得datagridview单元格中心的坐标

以便绘制线条,把这些标记了0的单元格,从上到下,依次连接起来




谢谢

------解决方案--------------------
C# code

DataGridViewCell cell = dgv[0, 0];
Rectangle rect = cell.ContentBounds;

------解决方案--------------------
监听 CellPainting 事件 在事件处理程序中绘制线条
------解决方案--------------------
C# code

private void dataGridView1_CellPainting(object sender,     system.Windows.Forms.DataGridViewCellPaintingEventArgs e)
{
    //e.CellBounds为单元格的区域,找到对应中心就很容易
    //把值绘制在单元格中 e.Value
    e.Handled=true; //不能漏了这句
}

------解决方案--------------------
探讨

引用:

C# code

DataGridViewCell cell = dgv[0, 0];
Rectangle rect = cell.ContentBounds;


如何把0给连起来呢