Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get a Combo Box to show column data?

Status
Not open for further replies.

borsker

Programmer
Jul 24, 2002
147
US
I am building an old fashion form using the form designer.
I am trying to add a combo box in my form that will be linked to a dbf. I want the combo box to see everything in column 2 of my dbf. Is there even a way to do this?

Example:
col1 col2 col3
1233 red 11x17
3954 blue 8.5x11
2658 white 3.25x9

I want the combobox pull down to have:
red
blue
white

There is about 300 records in the dbf and they are always changing. So to have the combobox look to this dbf that constantly changes would be great.
 
Are you saying there are 300 different values for col2? Or are there fewer, and you just want the combobox to display the unique (distinct) values?

Have you tried the combobox builder? After you drop the combobox control on your form, right-click and choose Builder.

Rick
 
Set these in the Property Sheet:
RowSourceType = 6
RowSource = dbf.col2, col1, col3
A unopened FoxPro combobox only displays its first column.

Andy Rice
San Diego, CA
 
Borsker,

If you want the combo to contain all three columns, do as Andy Rice suggested. If you want it to contain all three cols, but only show one of them, set the other column widths to zero, for example:

.Columnwidths = "0,80,0"

As Andy said, when the combo is closed, only the first of the columns will be visible. This is regardless of the setting of Columnwidths. If you want the second column to be visible when the combo is closed, just rearrange the cols within the rowsource.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
To add to what you added to what I added...
You can set the ColumnCount = 1 even when the RowSource contains multiple columns.
By doing that, you don't need to specify any ColumnWidth for the other columns.

Andy Rice
San Diego, CA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top