PRB: DropDown Combo Box May Display Partial String

Last reviewed: June 21, 1995
Article ID: Q89219
The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0
  • Microsoft Windows versions 3.0 and 3.1

SYMPTOMS

If the Visual Basic for Windows Combo Box Style is set to "0 - Dropdown Combo," you may see only the rightmost portion (right-aligned string) of the text displayed in the text box portion of the combo box at run time.

This problem only occurs if the combo box is too narrow to display the entire string.

WORKAROUND

To work around the problem, set the combo box Style property to "2 - Dropdown List" to change the Style property displays to the left part of the string.

Another alternative is to design the combo box with a wider dimension by increasing the width to greater than 1440 twips (the equivalent of one inch). For example, if you set the Width property to 4320 twips, the width increases to approximately three inches -- a size of combo box that would hold the entire string in the example shown in the More Information section below.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Demonstrate Behavior

  1. Start Visual Basic, or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.

  2. Add a one-inch wide combo box (that is, the width is equal to 1440 twips by default for a combo box) to Form1.

  3. Double-click the form or press F7 to open the Form_Click event procedure. Add the following code to the Form_Click event procedure:

       Sub Form_Click ()
          Combo1.AddItem "1234567890000000000"  '** 10 zeros
       End Sub
    
    

  4. Press F5 to run the example, or from the Run menu, choose Start.

  5. Click the form a couple of times.

  6. Select the down arrow on the combo box, and click one of the entries. You should see the entry being placed in the text box portion of the combo box, but instead the entry only displays zeros. The digits 1 through 9 are not displayed.

  7. If you change the Style property of the combo box to "2 - Dropdown List," and try the example, the left-aligned string displays in the combo box.


Additional reference words: 1.00 2.00 3.00
KBCategory: kbprg kbcode kbprb
KBSubcategory: PrgCtrlsStd


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.