|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataTable QuestionI'm a little bit counfused about the below scenario An user will be able to write within a combobox control for certain name ,like he types 'A' and all names begin in 'A' will be filled in combo and he may want to continue typing as AD' and all names that begin in 'AD' will be filled respectively Now it is my question. How to get it fileed more efiicient? I mean each time the user types a literal i call the function that filter a table in sql server and returns the data to the combobox OR fill the data table/data set/ array with all data (about 140.000 rows) by default and then loop throu a datatable and filter there Any ideas, thanks Hi,
Take a look at the combobox now has some autocomplete features. http://msdn2.microsoft.com/en-us/library/system.windows.forms.combobox.autocompletecustomsource.aspx Imports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim strConn As String Dim da As SqlDataAdapter Dim conn As SqlConnection Dim ds As New DataSet strConn = "Server = .;Database = NorthWind; Integrated Security = SSPI;" conn = New SqlConnection(strConn) da = New SqlDataAdapter("Select * from Products", conn) da.Fill(ds, "Products") Dim ac As New AutoCompleteStringCollection For Each dr As DataRow In ds.Tables("Products").Rows ac.Add(dr.Item("ProductName").ToString) ComboBox1.Items.Add(dr.Item("ProductName").ToString) Next ComboBox1.AutoCompleteMode = AutoCompleteMode.Append ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource ComboBox1.AutoCompleteCustomSource = ac End Sub End Class Ken -------------------- Show quoteHide quote "Uri Dimant" <u***@iscar.co.il> wrote in message news:OKZ58YuiGHA.1276@TK2MSFTNGP03.phx.gbl... > VS2005 > > I'm a little bit counfused about the below scenario > > An user will be able to write within a combobox control for certain name > ,like > he types 'A' and all names begin in 'A' will be filled in combo and he may > want to continue typing as > AD' and all names that begin in 'AD' will be filled respectively > > > Now it is my question. How to get it fileed more efiicient? I mean each > time the user types a literal i call the function that filter a table in > sql server and returns the data to the combobox OR fill the data > table/data set/ array with all data (about 140.000 rows) by default and > then loop throu a datatable and filter there > > > Any ideas, thanks > > > > > > > |
|||||||||||||||||||||||