Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Combo Box Display Value

1,149 views
Skip to first unread message

Sithu

unread,
Nov 3, 2009, 2:18:52 AM11/3/09
to
Hi all,

I have a combo box which has 2 columns : col1 an col2.
Bound column is col1.
When I select an item from the drop down list, it displays the value
of col1 as selected.
This is NOT what I want.

I want to display the values of col1 and col2 as selected.

How can I make it ?

With regards,
Sithu

Jürgen Wondzinski

unread,
Nov 3, 2009, 3:01:11 AM11/3/09
to
Hi Sithu,

> This is NOT what I want.

Yea, but you have to live with the fact, that sometimes there's a slight
discrepance between what we want and what we get ;)

A combobox is named Combobox, because it is a combination (!) of a textbox
for freetext-entry and an underlying listbox for predefined values. Since
the result is shown in the textbox part, you have only one value to show or
store.

If you want to have a combination of that two values for the user, why not
stuff the first column with that combined string and the second column with
the real identifier, and set the columnwith of column2 to 0 and boundcolumn
to 2 ?


--

wOOdy
Visual FoxPro Evangelist
Microsoft "Most Valuable Professional" 1996 to 2009

"*��)
�.���.�*��) �.�*�)
(�.��. (�.�` *
..�`.Visual FoxPro: It's magic !
(�.�``��*

Sithu

unread,
Nov 3, 2009, 3:13:10 AM11/3/09
to
I separated two columns because I want the equality of left alignment
of the values of second column.
My combo box is for UN port list. The first column is for port codes
and second column is for port names.
So, I want the left alignment of port names regardless of whatever
port code length of first column.

That is why not stuff the first column with that combined string.

Thank you, woody.

Stefan Wuebbe

unread,
Nov 3, 2009, 3:33:43 AM11/3/09
to

You can have invisible columns in your Combo.RowSource.
The first column is always the one that gets displayed in
the combo's textbox area, i.e. when the combo is collapsed.

So in your scenario, you can put your concatenated two
columns into column one of the rowsource.
That way it gets displayed as combo.DisplayValue.

And put the content of the two separate columns into
RowSource column two and three, because you want to
display them in the dropdown.

If you additionally set ColumnCount = 3, and
ColumnWidths = '0,100,100', the first (concatenated) column
would be the combo.DisplayValue, but not appear in the
drop-dpwn area.

Additionally you can have invisible columns, for instance
a fourth one that contains the actual key value.
It would not get displayed anyway when combo.ColumnCount=3,
but you can make it combo.Value when you set
combo.BoundColumn = 4
If the bound column is numeric, you'll need combo.BoundTo=.T.

hth
-Stefan

Sithu

unread,
Nov 3, 2009, 4:12:29 AM11/3/09
to
Thank you, Stefan.
You suggestion is great and very useful.
0 new messages