0

如何将列中的行数限制为Datagridview50 条记录并将其他 50 条放入同一列的下一列Datagridview?在我的 vb.net 项目中,我无法上下滚动。

Datagridview 从 Excel 工作表中提取数据。

感谢你的帮助

4

2 回答 2

0

尝试这个。

dataGridView1.RowCount = 50; //Let say we have 50 rows
if (dataGridView1.Rows.Count >= 50)
{
    //TODO:
}
于 2013-06-06T03:23:39.320 回答
0

我假设这是单列表..

dim tbl as DataTable       '--------> this is your displayed table
dim nLimit as Integer = 15 '----- this is your limit as you want
dim dc as DataColumn

'get column name
dim sCol as String = tbl.Columns(0).Name
dim nRow as Integer = tbl.rows.count

'how much column ?
dim n as Integer = nRow / nLimit 
if n * nLimit < nRow then n+= 1

for x as Integer = 1 to n
    dc = New DataColumn
    dc.DataType = System.Type.GetType("System.String")
    dc.Caption = sCol & n.ToString
    dc.ColumnName = sCol & n.ToString
    tbl.Columns.Add(dc)
next

然后你可以显示它...

于 2013-06-06T17:29:33.523 回答