FIX: First Item Can Disappear in Outline Control Style 0 or 2 (108659)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 3.0

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

  1. Start a new project in Visual Basic. Form1 is created by default.
  2. From the File menu, choose Add File. Add the MSOUTLIN.VBX control file from your WINDOWS\SYSTEM directory.
  3. Add an Outline custom control to the form.
  4. 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

  5. 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
    						
  6. 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.
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.

REFERENCES

"Microsoft Visual Basic Version 3.0: Professional Features Book 1: Custom Control Reference." See the Outline control, pages 256-257.

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:kbbug KB108659