Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox class properties don't make sense?
Message
From
19/04/1998 10:08:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/04/1998 00:00:31
Raul Davila
Davila Programming Services
Toa Alta, Puerto Rico
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00093227
Message ID:
00093242
Views:
24
>Hi:
>
> I just can't figure this out.
> I've spent a couple of hours reading the help explanation of all the ComboBox properties and some just don't make sense.
>
>Given the following:
>
>ITEMS.DBF (ID N(3), DESC C(20))
>165 A
>798 B
>194 C
>768 D
>
>WITH MyCombo
> .Style = 2 - Dropdown List
> .RowSourceType = 6 - Fields
> .RowSource = ITEMS.ID, DESC
> .BoundColumn = 1 && the column containing ITEMS.ID
> .ColumnWidths = 0,75 && don't want the ID visible, just the description
>ENDWITH
>
>Help says:
>BoundColumn: Determines which column of a multicolumn list box or combo box is bound to the Value property of the control.
>
>BoundColumn is 1 which is the column containing ITEMS.ID
>In the third item ID = 194
>Yet if I choose the third item .VALUE is 3 not 194!!!
>I did a SET STEP ON to see the object in the debugger and none of it's properties had the value 194.
>
>The only way I could get something was by setting .BoundTo = .T.
>Now .VALUE is 194 but nothing shows in the combo, not just that but I can't navigate through the items using the keyboard.
>When .BoundTo = .T. I can only choose an item using the mouse and even then the textbox part of the combo is empty.
>
>
>Help says:
>ListIndex: Specifies the index number of the selected item in a ComboBox or ListBox control.
>That's ok, the number of the item selected.
>But it also says:
>You can return the same value by using the control’s Value property.
>
>That is contradicting! Didn't it say that the .VALUE will have whatever is in the column identified by BoundColumn!?!?
>
>If BoundColumn = 1 and item #3 is selected then .VALUE should have whatever is in the first column, which is 194.
>
>Either I'm missing something simple or I really need someone to shed some light on this.
>
>TIA
Hi Raul,
You said you were able to see correct ID it should be 5.0, in 3.0 it was a problem to show an integer value.
First textbox part would be empty as normal, your boundcolumn=1 which is ID. Now I should understand something, don't you want to show the itemtext and have itemID (I think actually you want is it since you set columnwidths to 0,75)? If so simply boundcolumn=2 (text), get ID with .list(.listindex,1). You didn't tell about controlsource. Maybe it's the one causing trouble (ie: a lookup table). If so, I think your trouble is with displayvalue vs value. It's hard to explain what's going on by words. So a code might do it better, study with following class code and try with it, I hope everything will be more clear :
************************
*-- Class:        mycombo_edit (c:\temp\test.vcx)
*-- ParentClass:  combobox
*-- BaseClass:    combobox
*
DEFINE CLASS mycombo_edit AS combobox


Height = 22
Width = 100
DisabledBackColor = RGB(255,255,255)
aliasname = "None"
fieldname = "None"
Name = "mycombo_edit"


PROCEDURE When
  THIS.REQUERY
ENDPROC


PROCEDURE LostFocus
  this.value = this.displayvalue
ENDPROC


PROCEDURE Init
  WITH This
   .rowsourcetype = 3
   if lower(.fieldname)="none" or ;
    lower(.aliasname)="none"
    .fieldname = substr(.controlsource,rat(".",.controlsource)+1)
    .aliasname = substr(.controlsource,1,;
        rat(".",.controlsource)-1)
   endif
   .rowsource = [SELECT DISTINCT ]+THIS.fieldname +;
    [ as dummy FROM ]+this.aliasname+[ where !empty(]+THIS.fieldname + ;
    [) union ] +;
    [SELECT this.displayvalue as dummy ] +;
    [ FROM ]+this.aliasname + ;
    [ INTO cursor qq order by 1 ]
  ENDWITH
ENDPROC


ENDDEFINE
*
*-- EndDefine: mycombo_edit
**************************************************
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform