PRB: DropDown Combo Box May Display Partial String (89219)



The information in this article applies to:

  • the operating system: Microsoft Windows 3.1
  • the operating system: Microsoft Windows 3.0
  • Microsoft Visual Basic Standard Edition for Windows 1.0
  • Microsoft Visual Basic Standard Edition for Windows 2.0
  • Microsoft Visual Basic Standard Edition for Windows 3.0
  • Microsoft Visual Basic Professional Edition for Windows 2.0
  • Microsoft Visual Basic Professional Edition for Windows 3.0

This article was previously published under Q89219

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.

Modification Type:MajorLast Reviewed:12/12/2003
Keywords:kbprb KB89219