• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 477
  • 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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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