任何在vb.net中更快地绑定datagridview的代码 [英] Any code to bind datagridview faster in vb.net

查看:100
本文介绍了任何在vb.net中更快地绑定datagridview的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何代码可以在vb.net中更快地绑定datagridview



Is there any code to binding the datagridview faster in vb.net

Try
         Dim conn As New OleDbConnection(CnString)
         conn.Open()
         Dim cmd As New OleDbCommand(Query, conn)
         Dim ada As New OleDbDataAdapter(cmd)
         Dim dt As DataTable = New DataTable
         ada.Fill(dt)
         grd.DataSource = Nothing
         grd.DataSource = dt
         grd.AutoGenerateColumns = False
         conn.Close()
     Catch ex As Exception

     End Try



我使用上面的代码绑定datagridview。如果存在任何其他代码,请帮助我


I have used the code above for binding datagridview. Please help me if any other code exist

推荐答案

可能不是,该代码应该没问题。



如果它很慢,那么可能的原因是查询是问题,并且很可能是您检索的行太多,或者您要提取的列数据包括大数据类型(例如图像)。

查询返回的行越多,将它们加载到DGV中的速度就越慢。想想用户:如果你在显示器中加载了很多行,那么速度是你给他们的问题中最少的一个 - 随着行数的增加,找到他们正在寻找的信息变得越来越显示,困难和令人沮丧。作为一般规则,如果您显示的行数超过100行,那就太多了,您需要提供搜索和过滤。



您是否检查过您要返回多少数据?
Probably not, that code should be fine.

If it's slow, then the likely reason is that the query is the problem, and most likely that you are retrieving far too many rows, or the column data you are fetching includes a large data type (such as images).
The more rows your query returns, the slower it will be to load them into the DGV. Think about the user: if you are loading a lot of rows into the display, then speed is the least of the problems you are giving them - finding the information they are looking for becomes increasingly show, difficult, and frustrating as the row count increases. As a general rule, if you are showing more than 100 or so rows, that's too many, and you need to provide searching and filtering instead.

Have you checked how much data you are returning?


这篇关于任何在vb.net中更快地绑定datagridview的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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