[RESOLVED] how to set the Textbox autocomplete source to specific column in my datatable
hey guys
how to set the Textbox autocomplete source to specific column in my datatable?
how can i do that?
Re: how to set the Textbox autocomplete source to specific column in my datatable
You'd just have to use a custom source and keep it up to date yourself by handling the appropriate events of your DataTable.
Re: how to set the Textbox autocomplete source to specific column in my datatable
Re: how to set the Textbox autocomplete source to specific column in my datatable
hey
i know i have to use a custom source but what is the source exactly?
Re: how to set the Textbox autocomplete source to specific column in my datatable
Quote:
Originally Posted by
Naveen sharma
hiii jmm r u there
what??????
if you want jimm then send PM to him .
Re: how to set the Textbox autocomplete source to specific column in my datatable
Quote:
Originally Posted by
snakeman
hey
i know i have to use a custom source but what is the source exactly?
You set the AutoCompleteSource to Custom and then you have to add and remove items directly to the AutoCompleteCustomSource, which is itself a collection. You're going to have to manually get the data out of the column of your DataTable and manually add each value to the collection. You'll then need to handle the appropriate events of the DataTable to detect when a row is added, editied or deleted and then manually update the auto-complete collection.
Re: how to set the Textbox autocomplete source to specific column in my datatable
Assuming that you're using .NET 3.5, the easiest way to populate the auto-complete collection from the DataTable is using LINQ:
vb.net Code:
Me.TextBox1.AutoCompleteCustomSource.AddRange((From row In myDataTable.Rows.Cast(Of DataRow)() _
Select CStr(row("SomeColumn"))).ToArray()
Re: how to set the Textbox autocomplete source to specific column in my datatable
Re: how to set the Textbox autocomplete source to specific column in my datatable
Quote:
Originally Posted by
jmcilhinney
Assuming that you're using .NET 3.5, the easiest way to populate the auto-complete collection from the DataTable is using LINQ:
vb.net Code:
Me.TextBox1.AutoCompleteCustomSource.AddRange((From row In myDataTable.Rows.Cast(Of DataRow)() _
Select CStr(row("SomeColumn"))).ToArray()
hi jmc
i tried the above on form load but it says
HTML Code:
'Cast' is not a member of 'System.data.datarowcollection'
i am not using linq as i have no knowledge of it
can u pls. guide
thankx
Re: how to set the Textbox autocomplete source to specific column in my datatable
Quote:
Originally Posted by
kuldevbhasin
hi jmc
i tried the above on form load but it says
HTML Code:
'Cast' is not a member of 'System.data.datarowcollection'
i am not using linq as i have no knowledge of it
can u pls. guide
thankx
Are you using .NET 3.5? If not then LINQ and extension methods, which Cast is, are not available to you.
Re: [RESOLVED] how to set the Textbox autocomplete source to specific column in my da
thankx jmc for replying. i am using 3.5 as i am using vb.net 2008
do i have to include anything ?
i am using a webservice and gathering the data with the web reference.
there r about 12500 records in the master which i would want to fill in the autocomplet of the master selection
thankx
Re: [RESOLVED] how to set the Textbox autocomplete source to specific column in my da
i am doint it in the following manner :
vb Code:
Dim iRowCount As Integer = dTableMasterHelp.Rows.Count - 1
Dim i As Integer = 0
For i = 0 To iRowCount
Dim iRow As DataRow = dTableMasterHelp.Rows(i)
txtCustName.AutoCompleteCustomSource.Add(iRow!Name.ToString())
Next
but it is taking a lot of time and i feel that ur method would b much simpler and fast
hope to hear from u soon.
thankx
Re: [RESOLVED] how to set the Textbox autocomplete source to specific column in my da
Quote:
Originally Posted by
kuldevbhasin
thankx jmc for replying. i am using 3.5 as i am using vb.net 2008
That doesn't necessarily follow as VB 2008 can target .NET 2.0, 3.0 or 3.5.
You'll need to have imported the System.Linq namespace.
Re: [RESOLVED] how to set the Textbox autocomplete source to specific column in my da
thankx a lot jmc i got it working as u said it was targeting .net 2.0 and hence it was giving a error..
thankx a lot for being a great help as always