如何给DataGrid的RowHeader添加序列号? 在Microsoft Visual Studio 2005中,如何给DataGrid的RowHeader添加序列号?例如第一行就是1,第二行2,第三行3...如此类推...如何实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { // Display the company name in italics. e.Row.Cells[0].Text = (e.RowGridViewRow.RowIndex + 1).ToString(); } } 加一个模板列,在HTML里加上下面的代码<ItemTemplate> <%# Container.ItemIndex+1 %></ItemTemplate> private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor)) { e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4); } } zedGraph画曲线图的问题 线程里,如何向Listbox 上刷新数据呀? C#关于进程问题 善人帮个忙吧。在Repeater显示数据库里date列时间符合input1到input2之间的数据 C# 读取XML文件某个节点的值 紧急求助!!!VS2005不能装 一个应用程序如何获得领另一个应用程序的属性值 运行c#程序必须装.net framework吗? Webserver在引用时候怎样才能引用他的属性如: 介绍几本学习C#的好书 急求:在C# web应用程序页面上如何弹出一个文件保存的对话框呀呀 winform的DataGridView如何添加序号
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
// Display the company name in italics.
e.Row.Cells[0].Text = (e.RowGridViewRow.RowIndex + 1).ToString();
}
}
<ItemTemplate>
<%# Container.ItemIndex+1 %>
</ItemTemplate>
{
using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentUICulture),
e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
} }