如何设置winform的datagrid的rowhead(行头)显示的文字

jjstar 2005-03-23 11:55:37
如题
...全文
253 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yistudio 2005-03-23
  • 打赏
  • 举报
回复
tablestyles
bflovesnow 2005-03-23
  • 打赏
  • 举报
回复
private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)

{

int row = TopRow();

int yDelta = dataGrid1.GetCellBounds(row, 0).Height + 1;

int y = dataGrid1.GetCellBounds(row, 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("row{0}", row);

e.Graphics.DrawString(text, dataGrid1.Font, new SolidBrush(Color.Black), 12, y);

y += yDelta;

row++;

}

}

111,118

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧