|
-
Mar 26th, 2009, 12:59 AM
#1
Thread Starter
Hyperactive Member
[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?
-
Mar 26th, 2009, 01:09 AM
#2
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.
-
Mar 26th, 2009, 01:28 AM
#3
Member
Re: how to set the Textbox autocomplete source to specific column in my datatable
-
Mar 26th, 2009, 01:41 AM
#4
Thread Starter
Hyperactive Member
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?
-
Mar 26th, 2009, 01:43 AM
#5
Thread Starter
Hyperactive Member
Re: how to set the Textbox autocomplete source to specific column in my datatable
 Originally Posted by Naveen sharma
hiii jmm r u there
what??????
if you want jimm then send PM to him .
-
Mar 26th, 2009, 01:46 AM
#6
Re: how to set the Textbox autocomplete source to specific column in my datatable
 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.
-
Mar 26th, 2009, 01:54 AM
#7
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()
-
Mar 26th, 2009, 02:57 AM
#8
Thread Starter
Hyperactive Member
Re: how to set the Textbox autocomplete source to specific column in my datatable
thank you so much
-
Apr 6th, 2009, 07:40 AM
#9
Hyperactive Member
Re: how to set the Textbox autocomplete source to specific column in my datatable
 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
-
Apr 6th, 2009, 08:29 AM
#10
Re: how to set the Textbox autocomplete source to specific column in my datatable
 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.
-
Apr 6th, 2009, 12:28 PM
#11
Hyperactive Member
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
-
Apr 6th, 2009, 12:31 PM
#12
Hyperactive Member
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
-
Apr 6th, 2009, 06:47 PM
#13
Re: [RESOLVED] how to set the Textbox autocomplete source to specific column in my da
 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.
-
Apr 6th, 2009, 11:26 PM
#14
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|