问题描述
HI 朋友,这是surendra babu.我是vb.net的新手.
在一个项目中,我正在使用datagrid视图进行计费,并且我在datagrid中有一个组合框并将其绑定到表,所有工作都很好,但是我绑定的表有9000行(条目),所以当我单击组合框时,它需要10 15秒以加载该表.我想快速访问该表.我正在考虑在表格加载时绑定该表.所以请紧急帮助我.
我已经在datagrid中填充了组合框,并提供了代码,代码为
公共类frmOrders
Dim cb As ComboBox
私有子OrdersBindingNavigatorSaveItem_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理OrdersBindingNavigatorSaveItem.Click
Me.Validate()
Me.OrdersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.OrderDataSet)
结束子
私有子Form1_Load(ByVal发送者作为System.Object,ByVal e作为System.EventArgs)处理MyBase.Load
" TODO:这行代码将数据加载到" CustomerDataSet.Customers"表中.您可以根据需要移动或删除它.
Me.CustomersTableAdapter.Fill(Me.CustomerDataSet.Customers)
" TODO:这行代码将数据加载到"ProductDataSet.Products"表中.您可以根据需要移动或删除它.
Me.ProductsTableAdapter.Fill(Me.ProductDataSet.Products)
" TODO:这行代码将数据加载到" OrderDataSet.Order_Details"表中.您可以根据需要移动或删除它.
Me.Order_DetailsTableAdapter.Fill(Me.OrderDataSet.Order_Details)
" TODO:这行代码将数据加载到" OrderDataSet.Orders"表中.您可以根据需要移动或删除它.
Me.OrdersTableAdapter.Fill(Me.OrderDataSet.Orders)
结束子
私有子Order_DetailsDataGridView_CellLeave(ByVal发送者作为对象,ByVal e作为System.Windows.Forms.DataGridViewCellEventArgs)处理Order_DetailsDataGridView.CellLeave
如果不是cb什么都没有,那么
cb.SelectedIndex = cb.FindStringExact(cb.Text)
如果结束
结束子
私有子Order_DetailsDataGridView_EditingControlShowing(ByVal发送者作为对象,ByVal e作为System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)处理Order_DetailsDataGridView.EditingControlShowing
如果TypeOf e.Control是ComboBox,则
cb = e.Control
cb.DropDownStyle = ComboBoxStyle.DropDown
cb.AutoCompleteMode = AutoCompleteMode.SuggestAppend
cb.AutoCompleteSource = AutoCompleteSource.ListItems
如果结束
结束子
结束类
一切正常.但是问题是,当我单击
时,我在数据库产品表中有9000个产品datagrid视图中的组合框需要5到10秒才能显示列表.但是当我在普通组合框上使用它时,相同的产品表是非常快的,我的意思是它将在不到1秒的时间内访问.所以请朋友帮我感谢您对以前的解决方案的答复.
预先感谢:rose :: rose :: rose:
HI friends this is surendra babu. i am very new to vb.net.
in a project i am using datagrid view for billing and i have a combobox in datagrid and binded a table to it, all works fine but the table which i have binded has 9000 rows(entries) so when ever i click on combobox it take 10 to 15 second to load that table. i want fast access for that table. i am thinking of binding that table at form load. so please help me on this its urgent.
I have filled the combobox in datagrid and provide code the code is
Public Class frmOrders
Dim cb As ComboBox
Private Sub OrdersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersBindingNavigatorSaveItem.Click
Me.Validate()
Me.OrdersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.OrderDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''TODO: This line of code loads data into the ''CustomerDataSet.Customers'' table. You can move, or remove it, as needed.
Me.CustomersTableAdapter.Fill(Me.CustomerDataSet.Customers)
''TODO: This line of code loads data into the ''ProductDataSet.Products'' table. You can move, or remove it, as needed.
Me.ProductsTableAdapter.Fill(Me.ProductDataSet.Products)
''TODO: This line of code loads data into the ''OrderDataSet.Order_Details'' table. You can move, or remove it, as needed.
Me.Order_DetailsTableAdapter.Fill(Me.OrderDataSet.Order_Details)
''TODO: This line of code loads data into the ''OrderDataSet.Orders'' table. You can move, or remove it, as needed.
Me.OrdersTableAdapter.Fill(Me.OrderDataSet.Orders)
End Sub
Private Sub Order_DetailsDataGridView_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Order_DetailsDataGridView.CellLeave
If Not cb Is Nothing Then
cb.SelectedIndex = cb.FindStringExact(cb.Text)
End If
End Sub
Private Sub Order_DetailsDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles Order_DetailsDataGridView.EditingControlShowing
If TypeOf e.Control Is ComboBox Then
cb = e.Control
cb.DropDownStyle = ComboBoxStyle.DropDown
cb.AutoCompleteMode = AutoCompleteMode.SuggestAppend
cb.AutoCompleteSource = AutoCompleteSource.ListItems
End If
End Sub
End Class
all working fine. but the thing is, i have 9000 products in database product table when i click on
combo box in datagrid view it is taking 5 to 10 seconds to show list. but same product table when i use it on normal combo box its is super fast i mean it will access in less then 1 second. so please friends help me on this. thanks for u r response on previous solution.
Thank''s in advance :rose::rose::rose:
推荐答案
这篇关于vb.net datagrid组合框数据绑定以形成负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!