如何在不使用vb​​.net中的记录集的情况下在datagridview中添加数据 [英] How to add data in datagridview without using recordset in vb.net

查看:80
本文介绍了如何在不使用vb​​.net中的记录集的情况下在datagridview中添加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用vb​​.net中的记录集的情况下在datagridview中添加数据

解决方案

有几种方法,例如:

1)使用 DataTable [ ^ ]

为DataGridView创建新的数据表并设置 DataSource 属性。

2)使用 DataGridView.Rows [ ^ ]集合。



请按照链接;)


with datagridview1

.rows.add

.rows(.rows .count-1).cells(0).value =Test

.rows(.rows.count-1).cells (1).value =测试2

结束



如果您的数据网格中预先配置了2列。



如果没有,你将不得不通过添加列的相同方法。



希望这有助于。


您是否尝试过向数据添加日期?数据表可以升序和降序排序....然后您可以按日期升序排序。这样,新数据将永远位于顶部。 :)

How to add data in datagridview without using record set in vb.net

解决方案

There are few ways, for example:
1) using DataTable[^]
Create new datatable and set DataSource property for DataGridView.
2) using DataGridView.Rows[^] collection.

Please, follow the links ;)


with datagridview1
.rows.add
.rows(.rows.count-1).cells(0).value = "Test"
.rows(.rows.count-1).cells(1).value = "Test 2"
end with

Provided you have 2 columns preconfigured in your datagrid.

If not, You will have to go through the same method adding columns.

Hope this helps.


HAve you tried adding a date to the data? the datatable is sortable ascending and descending.... You may then sort by date ascending. That way the new data will always be on top. :)


这篇关于如何在不使用vb​​.net中的记录集的情况下在datagridview中添加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆