SetListBoxCurSel method (WinStudio scripts)

Applies To

IWSFormComponent interface, list box objects

Definition

Sets the current item in a list box.

Syntax

object.SetListBoxCurSel( integer )

  Part   Description
object Required. The name of a valid component object.
integer Required. The zero-based index number of the list item to be made the current selection.

Example

Sub Main
     Dim oListBox As IWSFormComponent
     Dim iCurrentRow As Integer
     Dim iCounter As Integer
     Dim strListBox As String
     Dim bSuccess As Boolean
     Dim iReturn As Integer
     Dim iRow As Integer
     oListBox = ThisForm.Components( "ListComboBox" )
     '  Fill list box 
     oListBox.ListSourceScriptAddListItem( "Item 1" )
     oListBox.ListSourceScriptAddListItem( "Item 2" )
     oListBox.ListSourceScriptAddListItem( "Item 3" )
     oListBox.ListSourceScriptAddListItem( "Item 4" )
     oListBox.ListSourceScriptAddListItem( "Item 5" )
     '  Dislplay list box properties
     iCurrentRow = oListBox.GetListBoxCurSel
     MsgBox( "Number Items = " + CStr( oListBox.GetListBoxCount )  + vbLf + _
                    "Current Selection = " + CStr( iCurrentRow )  + vbLf + _
                    "Text = " + oListBox.GetListBoxText ( iCurrentRow ) )
    '  Display contents of list box
     strListBox  = ""
     For iCounter = 0 To oListBox.GetListBoxCount -1
          strListBox = strListBox + CStr( iCounter + 1 ) + "  "  + _
                                                oListBox.GetListBoxText ( iCounter ) + vbLf
     Next iCounter
     MsgBox (strListBox)
      '  Set list box to second entry
     iRow = 1
     bSuccess = oListBox.SetListBoxCurSel( iRow )
     '  Insert new items at the second position
     iReturn  = oListBox.InsertListBoxString( iRow, "New Row Entry 1" )
     iReturn  = oListBox.InsertListBoxString( iRow, "New Row Entry 2" )
     '  Display contents of list box
     strListBox  = ""
     For iCounter = 0 To oListBox.GetListBoxCount -1
          strListBox = strListBox + CStr( iCounter + 1 ) + "  "  + _
                              oListBox.GetListBoxText ( iCounter ) + vbLf
     Next iCounter
     MsgBox (strListBox)
     '  Delete one of the rows just added
     oListBox.DeleteListBoxString(iRow + 1)
     '  Display contents of list box
     strListBox  = ""
     For iCounter = 0 To oListBox.GetListBoxCount -1
          strListBox = strListBox + CStr( iCounter + 1 ) + "  "  + _
                              oListBox.GetListBoxText ( iCounter ) + vbLf
     Next iCounter
     MsgBox (strListBox)
End Sub