Compartir a través de


AutoHideScrollBar Property

Shows or hides the scroll bar in a ListBox control. Read/write at design time and run time.

Note

If the list box is empty or if all items in the list box are visible, the scroll bar does not display.

ListBox.AutoHideScrollBar [= nValue]

Return Value

  • nValue
    Specifies a value that determines when a scroll bar is visible in a list box.

    The following table lists the values for nValue.

    nValue Description

    0

    Always show scroll bar. (Default)

    1

    Show scroll bar only if items in the list box cannot be fully displayed.

Remarks

Applies To: ListBox Control

When drawing scroll bars, Visual FoxPro respects the setting for the IntegralHeight property.

Example

The following example creates a list box on a form and specifies an array as the source of the items in the list box. In the user-defined class list box class, lstMyListbox, the AutoHideScrollBar property is set to 1 so that the scroll bar only appears if the number of items in the list box can't be fully displayed. Resize the form to adjust size of the list box.

The steps performed in this example appear as follows:

  • Clear the main Visual FoxPro window using the CLEAR command.

  • Create an array called gaMyListArray using the DIMENSION command.

  • Fill the array with letters using the FOR...ENDFOR and STORE commands.

  • Create a form using the CREATEOBJECT( ) function.

  • Add a CommandButton control based on the user-defined cmdMyCmdButton class by calling the AddObject method.

  • Add a ListBox control based on the custom lstMyListBox class by calling the AddObject method.

  • Specify an array as the row source type for the list box by setting the RowSourceType property to 5 (Array).

  • Specify the array gaMyListArray as the row source for the list box by setting the RowSource property.

  • Show the command button by setting the Visible property.

  • Show the list box by setting the Visible property.

  • Display the form by calling the form's Show method.

  • Begin event processing by calling the READ EVENTS command.

  • Define the user-defined cmdMyCmdButton class based on the CommandButton control using the DEFINE CLASS command. The code in the DEFINE CLASS command sets properties for the user-defined class and defines procedures.

  • Define the user-defined lstMyListBox class based on the ListBox control using the DEFINE CLASS command. The code in the DEFINE CLASS command sets properties for the user-defined class and defines procedures.

CLEAR
DIMENSION gaMyListArray(10)
FOR gnCount = 1 to 10  
   STORE REPLICATE(CHR(gnCount+64),6) TO gaMyListArray(gnCount)
NEXT   

frmMyForm = CREATEOBJECT('Form')  
frmMyForm.AddObject('cmbCommand1','cmdMyCmdBtn')  
frmMyForm.AddObject('lstListBox1','lstMyListBox')  
frmMyForm.lstListBox1.RowSourceType = 5  
frmMyForm.lstListBox1.RowSource = 'gaMyListArray' 
frmMyForm.cmbCommand1.Visible =.T.  
frmMyForm.lstListBox1.Visible =.T.  
frmMyForm.Show 
READ EVENTS  

DEFINE CLASS cmdMyCmdBtn AS CommandButton  
   Caption = '\<Quit'  
   Cancel = .T.  
   Left = 125  
   Top = 210  
   Height = 25  
   PROCEDURE Click
      CLEAR EVENTS  
      CLEAR  
ENDDEFINE

DEFINE CLASS lstMyListBox AS ListBox  
   Left = 10  
   Top = 30  
   Anchor = 5
   AutoHideScrollBar = 1
ENDDEFINE

See Also

Reference

RowSource Property
RowSourceType Property

Other Resources

Properties (Visual FoxPro)