Vb.net 限制行数
如何将Vb.net 限制行数,vb.net,datagridview,Vb.net,Datagridview,如何将Datagridview列中的行数限制为50行,并将其他50行放入同一Datagridview上的下一列?在我的vb.net项目中,我不能上下滚动 Datagridview从excel工作表中提取数据 感谢您的帮助试试这个 dataGridView1.RowCount = 50; //Let say we have 50 rows if (dataGridView1.Rows.Count >= 50) { //TODO: } 我假设这是一个单列表 dim tbl as Da
Datagridview
列中的行数限制为50行,并将其他50行放入同一Datagridview
上的下一列?在我的vb.net项目中,我不能上下滚动
Datagridview从excel工作表中提取数据
感谢您的帮助试试这个
dataGridView1.RowCount = 50; //Let say we have 50 rows
if (dataGridView1.Rows.Count >= 50)
{
//TODO:
}
我假设这是一个单列表
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
dim tbl as DataTable'---------->这是您显示的表
dim nLimit as Integer=15'----这是您想要的限制
dim dc作为数据列
'获取列名
dim sCol as String=tbl.Columns(0).Name
dim nRow as Integer=tbl.rows.count
“多少钱?
尺寸n为整数=nRow/nLimit
如果n*nLimit
然后你可以展示它…谢谢你的快速回答,但是//TODO:我不知道怎么做。这只是一个提示或注释,你的任务将从哪里开始。希望它能帮助您:)请,展示一些代码如何将行添加到datagridview?或者使用了
datagridview.DataSource
?你试过我的答案吗。。我看了你的个人资料,你从不投票给别人的答案。。为什么?