首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么获取DataGrid当前页中第一行的行号

2013-11-23 
如何获取DataGrid当前页中第一行的行号现在有一个DataGrid,有100条数据,是带滚动条的。现在向下拉动滚动条

如何获取DataGrid当前页中第一行的行号
现在有一个DataGrid,有100条数据,是带滚动条的。现在向下拉动滚动条后,怎么知道现在显示的第一行是所有记录中的第几行?
[解决办法]
是啊,弄个id(序列号)从头到尾就是了。不想显示还可以隐藏,想取就取。
[解决办法]
DataGrid.HitTestInfo.Row
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.datagrid.hittestinfo.row(v=vs.80).aspx
[解决办法]

dataGridView1.FirstDisplayedScrollingRowIndex

[解决办法]


private void Form1_Load(object sender, System.EventArgs e)
{
    dataGridView1.Dock = DockStyle.Fill;
    dataGridView1.DataSource = System.Drawing.Imaging.ImageCodecInfo.GetImageDecoders();
}
 
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
    System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X,
        e.RowBounds.Location.Y,
        dataGridView1.RowHeadersWidth - 4,
        e.RowBounds.Height);
 
    TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
        dataGridView1.RowHeadersDefaultCellStyle.Font,
        rectangle,
        dataGridView1.RowHeadersDefaultCellStyle.ForeColor,
        TextFormatFlags.VerticalCenter 
[解决办法]
 TextFormatFlags.Right);
}

http://www.cnblogs.com/JuneZhang/archive/2011/11/21/2257630.html
自己看一下

热点排行