C# DataGrid生成序号列问题 this.dataGrid2.GetCellBounds(row, 0)你要判断 是否 数据行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int row = 0; int yDelta = dataGrid1.GetCellBounds(0, 0).Height + 1; int y = dataGrid1.GetCellBounds(0, 0).Top + 2; CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember]; while (y < dataGrid1.Height - yDelta && row < cm.Count)//显示行索引 { //get & draw the header text... string text = string.Format("{0}", row); e.Graphics.DrawString(text, dataGrid1.Font, new SolidBrush(Color.Black), 12, y); y += yDelta; row++; } roselxy1981 你说的这样不可以啊!我试过了,还是没有序号列显示啊! 可以把完整的代码发给我吗? 为什么不 用 foreach(DataRow dr in ds2.Tables[0].Rows){}不明白搂住想做什么,要增加一列来做序号 这个序号做什么得 需不需要 在 datagrid里显示?不管需不需要显示。 这一列添加在 dataset的table中不是更便捷么?this.dataGrid2.GetCellBounds(row, 0).Y + 2出错的话 建议搂住打断点 调试 ,跟踪一下row的值。看看到底是执行到哪里出错了, 出错时 row是多少 简单的ReportViewer问题 如何使用C# 写游戏加速程序~?~ 窗体的事件和窗体的消息谁先执行? dev 的Gridcontrol 控件的CardView问题 用过的进来 正则表达式如何匹配 [ 符号 和这个 ] 符号 求一sql语句,分都给他,在线等 在线等, 求助自绘按扭 为什么这么做不行 窗口无法隐藏的问题 各位高手,帮个忙!我想在Form上生成一个点阵式的图像,不知道怎么弄 c#winform多线程 开发snmp网管软件,需要具备什么知识,用什么工具开发快,以及各个工具的有缺点 ? datagridview问题,大家来看看
int yDelta = dataGrid1.GetCellBounds(0, 0).Height + 1;
int y = dataGrid1.GetCellBounds(0, 0).Top + 2; CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember]; while (y < dataGrid1.Height - yDelta && row < cm.Count)//显示行索引
{
//get & draw the header text...
string text = string.Format("{0}", row);
e.Graphics.DrawString(text, dataGrid1.Font, new SolidBrush(Color.Black), 12, y);
y += yDelta;
row++;
}
foreach(DataRow dr in ds2.Tables[0].Rows)
{}
不明白搂住想做什么,
要增加一列来做序号 这个序号做什么得 需不需要 在 datagrid里显示?
不管需不需要显示。 这一列添加在 dataset的table中不是更便捷么?this.dataGrid2.GetCellBounds(row, 0).Y + 2出错的话 建议搂住打断点 调试 ,跟踪一下row的值。看看到底是执行到哪里出错了, 出错时 row是多少