DataGridView的Cell里面如何画一条直线 要在cell里面画条直线代表业务的完成情况(百分制)求一个思路 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 处理DataGridView的CellPainting 事件就行了,如:DataGridView dv;dv.CellPainting += new DataGridViewCellPaintingEventHandler(dv_CellPainting);void dv_CellPainting(object sender, DataGridViewCellPaintingEventArgs e){ e.Graphics.DrawLine(SystemPens.ControlText, e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Right, e.CellBounds.Bottom);} 我只是随便写的,你可以再参考下:private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e){ if (e.ColumnIndex == 2) { e.PaintBackground(e.CellBounds, true); e.PaintContent(e.CellBounds); Rectangle rect = new Rectangle(e.CellBounds.X, e.CellBounds.Y+(e.CellBounds.Height-5)/2, e.CellBounds.Width,5) ; e.Graphics.FillRectangle(SystemBrushes.ControlText, rect); //e.Graphics.DrawLine(SystemPens.ControlText, e.CellBounds.X, e.CellBounds.Y + e.CellBounds.Height / 2, e.CellBounds.Right, e.CellBounds.Y + e.CellBounds.Height / 2); e.Handled = true; }} 如何让messagebox对话框弹出后,永远在所有窗口前面呢? winform文本框限制全角字符的输入!在线等! 下一条上一条 C# 事件理解问题 请高手帮推荐C#好书 XML操作?问题? WinForm中发邮件出现异常? 如何实现鼠标HOOK? 这段串口通信程序有什么问题?高分相送!!! C#的窗体中有没有类似VB中的Resize事件? ●●●●●●●一刷卡,把刷卡人的信息存入数据库,这需要如何处理啊●●●● DataGridView选择相同或相似行的问题
DataGridView dv;
dv.CellPainting += new DataGridViewCellPaintingEventHandler(dv_CellPainting);
void dv_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
e.Graphics.DrawLine(SystemPens.ControlText, e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Right, e.CellBounds.Bottom);
}
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 2)
{
e.PaintBackground(e.CellBounds, true);
e.PaintContent(e.CellBounds); Rectangle rect = new Rectangle(e.CellBounds.X, e.CellBounds.Y+(e.CellBounds.Height-5)/2, e.CellBounds.Width,5) ;
e.Graphics.FillRectangle(SystemBrushes.ControlText, rect);
//e.Graphics.DrawLine(SystemPens.ControlText, e.CellBounds.X, e.CellBounds.Y + e.CellBounds.Height / 2, e.CellBounds.Right, e.CellBounds.Y + e.CellBounds.Height / 2);
e.Handled = true;
}
}