Solved

Loading datatable rows into a textbox

Posted on 2012-04-02
4
472 Views
Last Modified: 2012-04-03
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
Comment
Question by:deanlee17
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 500 total points
ID: 37797004
Hi,
You can use it as foolowing:

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


Thanks
0
 

Author Comment

by:deanlee17
ID: 37799646
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
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 37799651
Just trim the data so use as following:

r.Item(1).ToString().Trim()
0
 

Author Comment

by:deanlee17
ID: 37799660
Ah of course.

Thanks alot.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question