Loading datatable rows into a textbox

Posted on 2012-04-02
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


            For Each r In dt1.Rows



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...


Many Thanks,
Question by:deanlee17
  • 2
  • 2
LVL 16

Accepted Solution

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

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


Author Comment

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) + ")")
LVL 16

Expert Comment

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


Author Comment

ID: 37799660
Ah of course.

Thanks alot.

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with opening combobox using VB.NET. 3 26
VB.NET Textbox input validation 4 41
Generate Unique ID in VB.NET 21 69
Please explain purpose of GZIP 4 37
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

820 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