Solved

Multiple columns ComboBox and ListBox

Posted on 1998-04-13
7
321 Views
Last Modified: 2010-08-05
I'm working in vb4. I'm using the Microsoft Forms 2.0 OCX.
I switched a ComboBox to ColumnCount = 2. I'm getting data from a recordset.
How can I do to add items to the first and second columns?
I know how to work with standard ComboBoxes: ComboBox1.AddItem "Hello", but i don't know how to send data to thhe second column, and my help file doesn't work.
How do you work with multiple column comboboxes?
How do you extract items?
Which is the propertie that allows you to do that?
Thanks
Ivan Babic
ibabic@hotmail.com
PD: The same question for ListBoxes, please. I figure out it should be the same, but you never know.
0
Comment
Question by:ibabic
7 Comments
 

Author Comment

by:ibabic
ID: 1461156
Edited text of question
0
 

Expert Comment

by:tapsbin
ID: 1461157
Just wait for few hours...i will answer...

It seems to me that by changing the ColumnCount = 2 ...it is
only a logical second column so that you go on adding items
and it will appear columnwise...

But yes i will clearify you within few hours...

Thanks,

TAPS

0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1461158
To assign values to an item beyond the first column, use the List or Column property and specify the row and column of the item. I can assign all at a time if do this:
object.additem ValueCol1 & vbtab & ValueCol2 & ......

Extracticon (of the imagelist control) is a method, not a property. You can use it to extract a icon of the imagelist to assign it to a mousepointer for example.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ibabic
ID: 1461159
fguerreiro:
I didn't say Extracticon. i said Extract Item from the Combobox or the ListBox.
For example :
If i have this Access TABLE :
     Code                Name
     00001               Ivan Babic
     00002               F. Guerreiro

How can i fill the combo so that any of those values has an exact place in the list? i mean, there should be a propertie in the combobox that lets me extract a value like this:
Msgbox "This is the name : " & ComboBox1(Row(2), Column(2))
and it will show me this :
        This is the name : F. Guerreiro
I don't wanna work anymore with functions like Right(Combobox1,5) in order to get the code of a person. I need to work with column numbers. How can i do it?

Thanks
Ivan Babic
ibabic@hotmail.com
PD : I know how to get the row number back (with listindex). What i need is to get the column number. to use it.
0
 

Expert Comment

by:tapsbin
ID: 1461160
I was confused reagarding the standard combo box and the microsoft forms 2.0 control combo box...

I will have to work it out..Sorry for your waiting...

Thanks,

TAPS

0
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 50 total points
ID: 1461161
ibabic,

AddItem method will add text in the first column only, to use the other columns you must use List property.

Example:

Private Sub Form_Load()
 Dim Index As Integer

 Index = ComboBox1.ListCount
 Call ComboBox1.AddItem("Column1", Index)
 ComboBox1.List(Index, 1) = "Column2"  '1 means the second column
End Sub

You can use the same code for ListBox control.
0
 

Author Comment

by:ibabic
ID: 1461162
bin_huwairib:
I tried what you said, and it works!!!
Now i have another problem.
When i close the project (vb4) and i try to reopen it, it gives me trouble. VB4 tries to open the MsForms 2.0 Combobox as an old one, i mean, as a MsForms 1.0 ComboBox. And of course, it gives me an error like :
Line 218: The Property Size Name of CD_CAMPAÑA is not valid.
Line 220: Couldn't load the Property ColumnCount of CD_CAMPAÑA .
etc...
It's because it's trying to open the combobox as a standard vb4 combo. How can i fix it?
Ivan Babic
ibabic@hotmail.com
PD: Also for ListBoxes
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

679 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