INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Combo Box

How to create an "auto-fill" combox (Like internet explorer) in a prg format by mgagnon
Posted: 19 Apr 02 (Edited 23 Jun 03)

*Written By Mike Gagnon (MGagnon @ Tek-Tips)
*Converted Class to PRG format by Ben Stack (BlindPete @ Tek-Tips) 4/2002
* Additional code for spaces in values by viettla


*Example
_screen.addobject("oCB","ImprovedComboBox")
_Screen.oCB.Left = 10
_Screen.oCB.Top = 10
_screen.oCB.Width = 200
_screen.oCB.rowsource = "TestCombo" && Alias Name
_screen.oCB.rowsourcetype = 2  &&Alias
_Screen.oCB.visible = .t.
*_screen.RemoveObject("oCB") && this code in command window removes the combobox
 
DEFINE CLASS "ImprovedComboBox" AS COMBOBOX
acstyle = 2
lastdisplayvalue = ""
lastsellenght = 0
lastselstart = 0
style = 0
 
 PROCEDURE InteractiveChange
  LOCAL lnStyle, lnLastKey, lcDisplayValue
lnLastKey=lastkey()
lnStyle = this.style
IF this.style = 2
    this.style = 0
ENDI
IF (lnLastKey>=32 and lnLastKey<=126)
    IF this.selstart>=1
        lcDisplayValue=substr(this.displayvalue,1,this.selstart-1)+(chr(lnLastKey))
    ELSE
        lcDisplayValue=(chr(lnLastKey))+allt(this.displayvalue)
    ENDI
    IF empty(lcDisplayValue)
        lcDisplayValue=allt(chr(lnLastKey))
    ENDI
    FOR i = 1 to this.listcount
            If Upper(lcDisplayValue) == Upper(Substr(This.List(i),1,Len(lcDisplayValue)))
                This.DisplayValue=This.List(i)
                This.SelStart=Len(lcDisplayValue)
                nlLength=Len(Allt(This.DisplayValue))-Len(lcDisplayValue)
                This.SelLength=Iif(nlLength <0,0,nlLength)
                this.lastdisplayvalue = this.displayvalue
                this.lastselstart = this.selstart
                this.lastsellenght = this.sellenght
                RETURN
            ENDI
    ENDFOR
ENDIf
ENDPROC
ENDDEFINE


Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close