Solved

Loading datatable rows into a textbox

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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 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