如何在datagrid数据项前加序号 能说清楚点吗?你的意思是在DataGrid的每行前面加个序号吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用强类型的数据集方式,自己作出一个ID列,很EASY的。 webform or winform? if it is for webform, add a template column <asp:TemplateColumn HeaderText="序号"> <ItemTemplate> <%# Container.ItemIndex+1%> </ItemTemplate> </asp:TemplateColumn> 在做table時做一個id列,之後用檢測當前的courent+1的方法每次提交時自動比當前最后一個行數加1就可以了, private void dtgMain_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { int row = 0; int yDelta = dtgMain.GetCellBounds(row, 0).Height + 1; int y = dtgMain.GetCellBounds(row, 0).Top + 2; CurrencyManager cm = (CurrencyManager) this.BindingContext[dtgMain.DataSource, dtgMain.DataMember]; while(y < dtgMain.Height - yDelta && row < cm.Count) { //get & draw the header text... string text = string.Format("row{0}", row); e.Graphics.DrawString(text, dtgMain.Font, new SolidBrush(Color.Black), 12, y); y += yDelta; row++; } } 数组的CopyTo有什么用处啊? ASPxDateEdit这个控件里按钮的汉化 不太写代码了,今天发现MaximumSize、MinimumSize属性有意思的问题。 farpoint控件如何获取所选单元格的内容 跪求C#写的WEB SERCICE例子(要有代码),本人学习用. 问一个很简单的问题. vs.net startup error,help! 在MDI中, 想让所有的子窗体都失去焦点 C#获取exe文件48*48图标 请大家帮帮小妹看看这个问题好吗,进来者有分 C#的两个关于类型的问题! textbox和buttons之间的焦点获得问题
<ItemTemplate>
<%# Container.ItemIndex+1%>
</ItemTemplate>
</asp:TemplateColumn>
{
int row = 0;
int yDelta = dtgMain.GetCellBounds(row, 0).Height + 1;
int y = dtgMain.GetCellBounds(row, 0).Top + 2;
CurrencyManager cm = (CurrencyManager) this.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
while(y < dtgMain.Height - yDelta && row < cm.Count)
{
//get & draw the header text...
string text = string.Format("row{0}", row);
e.Graphics.DrawString(text, dtgMain.Font, new SolidBrush(Color.Black), 12, y);
y += yDelta;
row++;
}
}