读书人

怎么获得datagridview单元格中心的坐标

发布时间: 2012-05-28 17:59:33 作者: rapoo

如何获得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给连起来呢

读书人网 >C#

热点推荐