Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

Loading datatable rows into a textbox

Hi Experts,

I am currently using a textbox as a search field and am using autocomplete as follows...

 Dim r As DataRow

            C1TextBox1.AutoCompleteCustomSource.Clear()

            For Each r In dt1.Rows

                C1TextBox1.AutoCompleteCustomSource.Add(r.Item(0).ToString)

            Next

This returns the name of the company, which is all well and good. But i'd also like to have the company reference next to the company name in brackets, is this possible? I am currently pulling back the company reference in the second column of the data table.

So I would like...

COMPANYNAME (COMPANYREF)


Many Thanks,
Dean
0
deanlee17
Asked:
deanlee17
  • 2
  • 2
1 Solution
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,
You can use it as foolowing:

C1TextBox1.AutoCompleteCustomSource.Add(r.Item(0).ToString + " (" + r.Item(1).ToString + ")")


Thanks
0
 
deanlee17Author Commented:
Ok we are almost there, see attached print screen, the closing bracket almost has a tab before it on some drop down items?

Code is currently...

C1TextBox1.AutoCompleteCustomSource.Add(r.Item(1).ToString + " (" + r.Item(0) + ")")
problem.png
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Just trim the data so use as following:

r.Item(1).ToString().Trim()
0
 
deanlee17Author Commented:
Ah of course.

Thanks alot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now