我想在在两个指定的单元格中绘制一条直线,我使用下面的语句就是没效果,唉!
例如:我想绘在dataGridView2[0, 1]和dataGridView2[1, 5] 之间绘一绿色的直线。 private void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
e.Graphics.DrawLine( new Pen(Brushes.Green,3), dataGridView2[0, 1].ContentBounds.Location, dataGridView2[1, 2].ContentBounds.Location);
}
例如:我想绘在dataGridView2[0, 1]和dataGridView2[1, 5] 之间绘一绿色的直线。 private void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
e.Graphics.DrawLine( new Pen(Brushes.Green,3), dataGridView2[0, 1].ContentBounds.Location, dataGridView2[1, 2].ContentBounds.Location);
}
解决方案 »
- NetworkCredential 访问验证失败
- InitialData控件
- 请大家随便指点一下,没有代码
- .net编程资料
- c# dataGridView 光标选中文字,点别的按钮,如何让选中文字不变,而不是自动选中整行
- http://www.xmcsw.com/中的搜索技术是如何实现的!搜出的结果都是厦门的信息!和baidu\google的搜索有什么异同?200分
- 请问Dropdownlist与ListBox怎么联动?
- asp.net用户控件事件获取主界面数据~~
- 关于部署水晶报表的问题(部署到客户处老是提示"invalid parameter name")
- 手机上开发的程序怎么检测手机正在上传或下载数据?答对了给100分!!!!
- 如何获得两个时间段的跨的天数??
- 操作excel的问题
dataGridView2[1, 2].ContentBounds.Location); 为什么这样就是不行啊?!
http://www.500wan.com/pages/info/datachart/ssq/zoushi/bluezs_1.shtml
这个里面一样的效果,不过绘制直线是在dataGridView 中。
{
Graphics g = this.dataGridView1.CreateGraphics(); Point p1 = this.dataGridView1.GetCellDisplayRectangle(c1.ColumnIndex, c1.RowIndex, false).Location;
Point p2 = this.dataGridView1.GetCellDisplayRectangle(c2.ColumnIndex, c2.RowIndex, false).Location;
p1.Offset(c1.Size.Width / 2, c1.Size.Height / 2);
p2.Offset(c2.Size.Width / 2, c2.Size.Height / 2);
g.DrawLine(Pens.Blue, p1, p2);
}