GetListBoxText method (WinStudio scripts)
Applies To
IWSFormComponent interface, List component type objects
Definition
Returns a string containing the contents of a designated list item in a list box (List type component).
Syntax
object.GetListBoxText( integer )
Part | Description |
object | Required. A reference to a List component type object. |
integer | Required. A reference to the zero-based index number of the item in the list. |
Remarks
The return value is a string containing the contents of the designated list item.
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("list1") 'Check to verify that a list item is selected. 'If not, display a message and exit. iCurrentRow = oListBox.GetListBoxCurSel If iCurrentRow = -1 Then Application.ShowMessage("No list item selected!") Exit Sub End If 'Display list box properties. Application.ShowMessage("Number of items: " & oListBox.GetListBoxCount().ToString() _ & vbLf & "Current selection: " & (iCurrentRow + 1).ToString() & vbLf & _ "Text: " & oListBox.GetListBoxText(iCurrentRow)) 'Display contents of list box. strListBox = "" For iCounter = 0 To oListBox.GetListBoxCount() - 1 strListBox = strListBox & (iCounter + 1).ToString() & " " & _ oListBox.GetListBoxText(iCounter) & vbLf Next iCounter Application.ShowMessage("The following are the currently defined events:" _ & vbLf & 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 & (iCounter + 1).ToString() & " " & _ oListBox.GetListBoxText(iCounter) & vbLf Next iCounter Application.ShowMessage("Current list: " & vbLf & strListBox) 'Delete the rows just added. oListBox.DeleteListBoxString(iRow + 1) oListBox.DeleteListBoxString(iRow) 'Display contents of list box. strListBox = "" For iCounter = 0 To oListBox.GetListBoxCount() - 1 strListBox = strListBox & (iCounter + 1).ToString() & " " & _ oListBox.GetListBoxText(iCounter) & vbLf Next iCounter Application.ShowMessage("Current list: " & vbLf & strListBox) End Sub