Microsoft KB Archive/108659

= FIX: First Item Can Disappear in Outline Control Style 0 or 2 =

Article ID: 108659

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q108659



SYMPTOMS
When an Outline custom control has both:


 * Style property value of 0 or 2
 * Indent property value of 0 on an item

the first visible item in the outline incorrectly disappears when you initially click any other item at run time. The problem occurs both in the Visual Basic environment and in compiled EXE files.

By design, the item that has an Indent property of 0 should not display. However this should not have any effect on the items that do display.



WORKAROUND
The first item reappears as soon as you select it with the mouse or keyboard. The keyboard interface for the Outline control includes LEFT ARROW, RIGHT ARROW, UP ARROW, DOWN ARROW, HOME, END, PAGE UP, PAGE DOWN, plus sign (+), and minus sign (-).

You can prevent the disappearance of the first item as follows:


 * Do not use an Indent value of 0 on items in an Outline control that uses Style property values of 0 or 2. Instead, use an Indent value of 1 or greater. or


 * Add the Outline1.ListIndex=1 statement after you add all items and indents to the Outline control. This ListIndex method selects the first item automatically, working around the problem.



STATUS
Microsoft has confirmed this to be a bug in the Professional Edition of Microsoft Visual Basic version 3.0 for Windows. This problem has been corrected in Visual Basic version 4.0.



MORE INFORMATION
NOTE: An item that has an Indent property of 0 will be visible when you use Style property values of 1, 3, 4, and 5, which include pictures or tree lines. The bug mentioned in this article does not occur for these styles.

Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default. From the File menu, choose Add File. Add the MSOUTLIN.VBX control file from your WINDOWS\SYSTEM directory. Add an Outline custom control to the form. Select the Outline control and press the F4 key to display the Properties window. Set the Style property to 0 or 2:

0 - Text Only

or

2 - Plus/Minus and Text

  Double-click the form to display the code window. Add the following code to the Form Load event: Sub Form_Load For i = 0 To 4 ' Note that item 0 will not be visible, by design. outline1.AddItem Str$(i) outline1.Indent(i) = i     Next For i = 1 To 4 outline1.Expand(i - 1) = True Next ' Add the following statement to work around the bug: ' Outline1.ListIndex=1 End Sub  Start the program, or press the F5 key. To duplicate the problem, click any item except the first. The first item, 1, incorrectly disappears.

As long as you click any item except the first, the first item remains invisible. As soon as you click the first item, it correctly appears.</li></ol>

To work around the problem, add Outline1.ListIndex=1 to the end of the code listed in step 5. The ListIndex method selects the first item automatically.

<div class="references_section">