Microsoft KB Archive/190258

= BUG: Pressing ESC Twice in Combo Box Resets ListIndex Property =

Article ID: 190258

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a

-



This article was previously published under Q190258



SYMPTOMS
When you make a selection from a combo box and you reopen the combo box and press the ESC key twice, the ListIndex property of the combo box changes to zero even though an item is still selected.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The ListIndex property of a list box or combo box specifies the index number of the selected item in a combo box or list box control. The index number should be a non-zero value if an item is selected. However, in this case, it returns a zero value for the index number even though an item is selected.

Steps to Reproduce Behavior
The following example echoes the method being called and the value of the combo box ListIndex property each time either the Valid or KeyPress events of the combo box execute.   Run the following code from a program (.PRG) file: PUBLIC oform1 oform1=CREATEOBJECT("form1") oform1.SHOW

DEFINE CLASS form1 AS FORM AUTOCENTER = .T.        NAME = "Form1" DIMENSION aarray[1]

ADD OBJECT combo1 AS COMBOBOX WITH ; ROWSOURCETYPE = 5, ; ROWSOURCE = "thisform.aArray", ; HEIGHT = 24, ; LEFT = 144, ; TOP = 36, ; WIDTH = 100, ; NAME = "Combo1"

ADD OBJECT edit1 AS EDITBOX WITH ; HEIGHT = 109, ; LEFT = 12, ; TOP = 96, ; WIDTH = 348, ; NAME = "Edit1"

PROCEDURE LOAD DIME THIS.aarray[10] FOR lni = 1 TO ALEN[this.aArray] THIS.aarray[lni] = 'Number '+ALLTR(STR(lni)) ENDF ENDPROC

PROCEDURE combo1.VALID THISFORM.edit1.VALUE = PROGRAM+' '+STR(THIS.LISTINDEX)+ ; CHR(13)+ THISFORM.edit1.VALUE ENDPROC

PROCEDURE combo1.KEYPRESS LPARAMETERS nKeyCode, nShiftAltCtrl THISFORM.edit1.VALUE = PROGRAM+' '+STR(THIS.LISTINDEX)+ ; CHR(13)+ THISFORM.edit1.VALUE ENDPROC

ENDDEFINE  Click the down arrow of the combo box to open the combo box. Using the mouse, select "Number 2" from the combo box. This closes the combo box. Next, click the down arrow of the combo box to open the combo box again. Press the ESC key twice. The first click closes the drop-down combo box. The second ESC resets the value the ListIndex to zero (0).

