Microsoft KB Archive/272420

= BUG: ComboBox Text Is Missing When DoEvents Is in GotFocus Event =

Article ID: 272420

Article Last Modified on 5/12/2003

-

APPLIES TO

 Microsoft Visual Basic 6.0 Professional Edition, when used with:  Microsoft Windows 2000 Standard Edition

 Microsoft Windows 95

 Microsoft Windows 98 Standard Edition  Microsoft Visual Basic 6.0 Enterprise Edition, when used with:  Microsoft Windows 2000 Standard Edition</li></ul>

 Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q272420

<div class="symptoms_section">

SYMPTOMS
When the Animation/Transition Display Properties system setting is turned on, List Item text does not display in a ComboBox if a DoEvents statement is used prior to assigning the ListIndex property in the GotFocus event.

<div class="resolution_section">

RESOLUTION
Any of the following actions can be used to work around this behavior:


 * The DoEvents statement can be placed after the statement that sets the ListIndex.
 * The Style of the ComboBox can be set to 0 - Dropdown Combo.
 * The Animation/Transition setting can be cleared in the Effects tab of the Display Properties dialog.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> For Windows 98 or Windows 95:

On the Start menu, click Control Panel, select Display Properties, and then select the Effects tab to make sure that the Animate windows, menus and lists item is checked.

For Windows 2000:

On the Start menu, click Control Panel, select Display Properties, and then select the Effects tab to make sure that the Use transition effects for menus and tooltips item is checked.</li> Start a new Visual Basic Standard EXE project. Form1 is created by default.</li> Add two CommandButton controls and two ComboBox controls to Form1.</li> Set the Style property for both ComboBox controls to 2 - Dropdown List.</li>  Add the following code to the General Declarations section of Form1: Private Sub Combo1_GotFocus Combo1.ListIndex = 0 End Sub

Private Sub Combo2_GotFocus DoEvents Combo2.ListIndex = 0 End Sub

Private Sub Form_Load Command1.TabIndex = 0 Combo1.TabIndex = 1 Command2.TabIndex = 2 Combo2.TabIndex = 3 Combo1.AddItem &quot;ABC&quot; Combo2.AddItem &quot;ABC&quot; End Sub </li> Press the F5 key to run the program, and then click the drop-down arrow for ComboBox1.</li> Click on Form1, and then click the drop-down arrow for ComboBox2.</li> Click on Form1 and note that ListIndex element number zero (0) appears in ComboBox1. However, ListIndex element number zero (0) does not appear in ComboBox2. ComboBox2 remains blank.</li></ol>

Keywords: kbbug kbcombobox kbnofix KB272420

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.