Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComBox not working OK ? Help me, please...
Message
From
17/04/1998 13:29:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/04/1998 09:11:05
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00092835
Message ID:
00092947
Views:
26
Hi Chris,
If no failure again you already should have a copy of this in your mailbox.
For a quick start, in lostfocus of combo add :
*Combo.lostfocus
this.value = this.displayvalue
Why : Combo values source is another table and when you type in a
nonexistent item, although you see the typed value in combo (displayvalue),
value is empty() (no corresponding record), thus in table1value is set to
"". The above code makes base1.table1 value same as typed displayvalue and
displayvalue is blanked (reverse), but now you have the desired value in
your table. To also set the displayedvalue to field value add one more line
:
*Combo.lostfocus
this.value = this.displayvalue
this.displayvalue = this.value
Rather nasty but now everything is OK. One final adding (to ensure if
current value is nonexistent it's not shown blank).
*Combo.gotfocus
this.displayvalue=this.value
and with sparse setting (or dynamiccurrentcontrol) everything fits in place.
Also try this class :
************************
*-- 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
**************************************************
Set controlsource as you want. This one was especially for an addable combo
in grid. Better yet I use aliasname.fieldname same as controlsource so it is
in fact pulling all values from its own table. At the start user has no
selectable values but as s/he enters combo fills in with unique values of
that field. It works with buffered tables too (cool), dummy is for that
(maybe I should add this to KB section - first have your opinion too). To
use it in a grid (although just drag&drop but better) :
- After adding it delete default text1 of column (so no need to play with
currentcontrol).
- Do not touch sparse (test it)
- Increase grid.rowheight so combo fits
That's it.

> 1.1) How to show the list of a ComboBox with the keyboard, not with a
>click in the button ???
Press Alt+Downarrow
> 1.2) There is a way to select controls from a Grid faster than selecting
>it from the PEM window ???
My way (faster especially if browsing same method) :
Right click on grid, select edit, select desired column and dblclick, select
desired method, select desired subcontrol of grid in that code window. If
will write same code to a series of objects, write one, copy, again in code
window select object, paste.
Hope it was what you want.
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
Reply
Map
View

Click here to load this message in the networking platform