473,890 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multi column combo box in vb.net

Hi

Does anyone know how to create a multi column combo box from the same table?

Thanks,
Cindy
Nov 21 '05 #1
6 11785
Do you have a control that displays multi columns right now? If so post the
code to create the columns and the code that populates the datasource

"CindyH" <no**@none.co m> wrote in message
news:OX******** ******@TK2MSFTN GP15.phx.gbl...
Hi

Does anyone know how to create a multi column combo box from the same
table?

Thanks,
Cindy

Nov 21 '05 #2
No, what I really want is a combo box that is multi colum and autoformat.
I found an example of an autoformat, which is working well and now I need
the multi column part.
I have a customerID, lastname and firstname columns from same table
(dataset) that I would like to display, searching by last name.

This is the code I'm using for the autoformat:

It is in a module and I'm calling through the keyup event for the combobox.
---------------------------
Private Sub CboLastName_Key Up(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles CboLastName.Key Up

AutoComplete(Cb oLastName, e)

End Sub

----------------------------------------------------------------------------

Module Module1

Public Sub AutoComplete(By Val cbo As ComboBox, _

ByVal e As System.Windows. Forms.KeyEventA rgs)

' Call this from your form passing in the name

' of your combobox and the event arg:

' AutoComplete(cb oState, e)

Dim iIndex As Integer

Dim sActual As String

Dim sFound As String

Dim bMatchFound As Boolean

'check if the text is blank or not, if not then only proceed

If Not cbo.Text = "" Then 'if the text is not blank then only proceed

' If backspace then remove the last character

' that was typed in and try to find

' a match. note that the selected text from the

' last character typed in to the

' end of the combo text field will also be deleted.

If e.KeyCode = Keys.Back Then

cbo.Text = Mid(cbo.Text, 1, Len(cbo.Text) - 1)

End If

' Do nothing for some keys such as navigation keys...

If ((e.KeyCode = Keys.Left) Or _

(e.KeyCode = Keys.Right) Or _

(e.KeyCode = Keys.Up) Or _

(e.KeyCode = Keys.Down) Or _

(e.KeyCode = Keys.PageUp) Or _

(e.KeyCode = Keys.PageDown) Or _

(e.KeyCode = Keys.Home) Or _

(e.KeyCode = Keys.End)) Then

Return

End If

Do

' Store the actual text that has been typed.

sActual = cbo.Text

' Find the first match for the typed value.

iIndex = cbo.FindString( sActual)

' Get the text of the first match.

' if index > -1 then a match was found.

If (iIndex > -1) Then '** FOUND SECTION **

sFound = cbo.Items(iInde x).ToString()

' Select this item from the list.

cbo.SelectedInd ex = iIndex

' Select the portion of the text that was automatically

' added so that additional typing will replace it.

cbo.SelectionSt art = sActual.Length

cbo.SelectionLe ngth = sFound.Length

bMatchFound = True

Else '** NOT FOUND SECTION **

'if there isn't a match and the text typed in is only 1 character

'or nothing then just select the first entry in the combo box.

If sActual.Length = 1 Or sActual.Length = 0 Then

' cbo.SelectedInd ex = 0

' cbo.SelectionSt art = 0

' cbo.SelectionLe ngth = Len(cbo.Text)

' bMatchFound = True

MsgBox("Not Found")

bMatchFound = True

Else

'if there isn't a match for the text typed in then

'remove the last character of the text typed in

'and try to find a match.

'************** ************ NOTE *************** ***********

'COMMENT THE FOLLOWING THREE LINES AND UNCOMMENT

'THE (bMatchFound = True) LINE

'INCASE YOU WANT TO ALLOW TEXTS TO BE TYPED IN

' WHICH ARE NOT IN THE LIST. ELSE IF

'YOU WANT TO RESTRICT THE USER TO TYPE TEXTS WHICH ARE

'NOT IN THE LIST THEN LEAVE THE FOLLOWING THREE LINES AS IT IS

'AND COMMENT THE (bMatchFound = True) LINE.

'************** *************** *************** ***************

'/////// THREE LINES SECTION STARTS HERE ///////////

cbo.SelectionSt art = sActual.Length - 1

cbo.SelectionLe ngth = sActual.Length - 1

cbo.Text = Mid(cbo.Text, 1, Len(cbo.Text) - 1)

' MsgBox("Not Found")

'/////// THREE LINES SECTION ENDS HERE /////////////

' bMatchFound = True

End If

End If

Loop Until bMatchFound

End If

End Sub

End Module

"Chris" <cc*********@ho tmail.com> wrote in message
news:e2******** ******@TK2MSFTN GP14.phx.gbl...
Do you have a control that displays multi columns right now? If so post the code to create the columns and the code that populates the datasource

"CindyH" <no**@none.co m> wrote in message
news:OX******** ******@TK2MSFTN GP15.phx.gbl...
Hi

Does anyone know how to create a multi column combo box from the same
table?

Thanks,
Cindy


Nov 21 '05 #3
Cindy,

http://www.planet-source-code.com/vb...2934&lngWId=10

The only thing I did with is was looking at it,

I hope this helps,

Cor
Nov 21 '05 #4
"CindyH" <no**@none.com> 's wild thoughts were released on
Wed, 31 Aug 2005 16:14:49 -0500 bearing the following fruit:
Hi

Does anyone know how to create a multi column combo box from the same table?


Have you considered creating a usercontrol that inherits
from the combo box. You could then replace the drop down
with a control of your choice.

Jan Hyde (VB MVP)

--
Did you ever date a witch? Yes, but just for a spell. (Bob Thaves)

[Abolish the TV Licence - http://www.tvlicensing.biz/]

Nov 21 '05 #5
Hey, thanks - this looks like what I am looking for!
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Cindy,

http://www.planet-source-code.com/vb...2934&lngWId=10

The only thing I did with is was looking at it,

I hope this helps,

Cor

Nov 21 '05 #6
Thanks i gt so many funtionally in one control,i hop in future i can
also help ....,whn i gt core knowldge ..bt its never ending process :-)
Cindy H wrote:
Hey, thanks - this looks like what I am looking for!
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Cindy,

http://www.planet-source-code.com/vb...2934&lngWId=10

The only thing I did with is was looking at it,

I hope this helps,

Cor


Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5313
by: Diane Yocom | last post by:
Has anybody ever seen or written code for ASP that would mimic Access' multi-column combo box? Specifically, I have a drop down box that lists about 100 five-digit codes. Each of these codes has a long text description that explains what the code represents. I'd like to be able to show the code plus description when the drop down list is dropped down, but just the code when the list is not displayed, so that I don't have to have a...
27
3283
by: DraguVaso | last post by:
Hi, The Multi column comboBox is a well spoken control, that a lot of people desire, and a lot of people buildtheir own. I tested a lot of them, but none really was what i wanted to have. But does anybody knows where I can find the best Multi column combobox? One that supports a lot of columns, possiblities to get the values in each column for the selected item, adding a DataSource etc... It should be free, and if possible with the...
3
6703
by: Terri | last post by:
Hi, I'm using the following code to build a concatenated string from a multi-select combo. For Each varItem In Forms!frmreports!Combo1.ItemsSelected strSQL = strSQL & Forms!frmreports!Combo1.ItemData(varItem) & " OR =" Next varItem
2
6173
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box on my form contains a category ID (bound column, not visible, long integer) for the items listed on the form and a description (unbound column, visible, string.) I can "Sort Ascending" and "Sort Descending" on the visible description in the...
1
8090
by: Fujitsu | last post by:
Dear all, How can I have a multi-column combo box, that means more than 1 display member ? Thank you.
2
6556
by: Exick | last post by:
This is more of a minor annoyance/curiosity than a real problem, but I'm wondering if anyone here can provide some answers. I have a form bound to a table with lots of controls on it that are bound to fields of said table. I also have a combo box on the form that is unbound. I'm using it purely as a search mechanism. Anyway, the combo box dropdown is populated with data from a SQL query. There are 5 fields total, only the first 2 are...
3
2411
by: sparks | last post by:
This should be easy to do...well I thought so a combo box that needs mult entry types. if the columns are something like this 1 Caucasian 2 Hispanic 3 African American
12
4056
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just not several, to report using this code i found - Private Sub cmdPreview_Click()
1
3170
by: vgarzon | last post by:
Hi, I'm having issues setting a multi-column combobox in the right way. What I'm trying to do is that when I click on a table (access 2007 subform), a form should fill with the values of the record I clicked on. No problem until I have to fill correctly a multi-column combo for 2 reasons: - In the table I only have the value of one of the 2 columns (That can be solved if I query again one of my external tables, but if you have...
0
9826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11234
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10829
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7171
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6058
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4682
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.