datagridview中有很多隱藏行,自動增加序號是不把隱藏行算在內,只排序顯示出來的資訊的行號
求助!!!
uj5u.com熱心網友回復:
行號怎么來的,自己加的還是資料本身就有的uj5u.com熱心網友回復:
自己加的private void GV_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
GV.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
GV.RowHeadersDefaultCellStyle.Font,
rectangle,
GV.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
uj5u.com熱心網友回復:
void refresh()
{
int count = 1;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
if (row.Visible)
{
row.HeaderCell.Value = count++.ToString();
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/34606.html
標籤:C#
上一篇:VB Event ClientCountChanged As CbDelegate(Of Integer)是事件,不能呼叫,請使用RaiseEvent引發事件
