Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox OK only on 2nd DropDown() call.
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Combobox OK only on 2nd DropDown() call.
Miscellaneous
Thread ID:
00619138
Message ID:
00619138
Views:
41
I'm working on a combobox class that doesn't behave right!

What I *want* is the DropDown() event to repopulate the combobox with a list of values matching what the user has typed.

This class works the 2nd time I click on the DropDown arrow. The first time, though, it doesn't really drop down. It shows a single "graphical" line below the combo.

Any insight into this situation would be appreciated. Just copy the code below into a PRG and run it to see what I'm talking about.
*- TestCombo.prg
CREATE CURSOR cu_List (cFullName C(30))
INSERT INTO cu_List VALUES ("ANDERSON, BOB")
INSERT INTO cu_List VALUES ("ANDERSON, JACK")
INSERT INTO cu_List VALUES ("ANDERSON, STEVE")
INSERT INTO cu_List VALUES ("ANDERSON, JULIE")
INSERT INTO cu_List VALUES ("ALTON, JOHN")
INSERT INTO cu_List VALUES ("ALTON, JEFF")

oForm = CREATEOBJECT("Form")
oForm.AddObject("cboTest", "clsCombo")
oForm.cboTest.Visible = .T.
oForm.cboTest.DisplayValue = "AND"
oForm.Show(1)

USE IN cu_List

RETURN

DEFINE CLASS clsCombo AS combobox

  RowSourceType = 5
  RowSource = "This.aRowSource"
  Width = 200
  Format = "!"

  *-- Holds list of items selectable in this combobox.
  DIMENSION aRowSource[1]

  PROCEDURE Init
    This.Requery()
  ENDPROC

  PROCEDURE DropDown
    This.Requery()
  ENDPROC

  PROCEDURE Requery
    lcText = TRIM(This.DisplayValue)

    IF NOT EMPTY(lcText)
	SELECT cFullName FROM cu_List 	;
	  WHERE cFullName = lcText 	;
	  ORDER BY 1 					;
	  INTO ARRAY This.aRowSource
    ENDIF

    IF TYPE("This.aRowSource[1]") # "C"
	DIMENSION This.aRowSource[1]
	This.aRowSource = SPACE(40)
    ENDIF
  ENDPROC

ENDDEFINE
"Problems cannot be solved at the same level of awareness that created them." - Albert Einstein

Bruce Allen
NTX Data
Next
Reply
Map
View

Click here to load this message in the networking platform