Well, Chip--I guess I did muddy the waters a bit.
I did figure out how to deal with the listview when all the items were in the 
xml file.

This is not what I asked about at first.
Sorry about that.
So, I still don't see why this script does not work.
Note: here is the script that attempts to add the 3 items from the .vbs file.  
It doesn't work!
Only the names are displayed in the listview, and when trying to retrieve the 
colors and numbers, the subscripted items get the other names from the list.
Lines 27 through 46, and line 88 must not be correct.

Option Explicit 

' We'll assume we have a list view whose ID is "listview1" which contains no 
items by default 

Dim isVisible : isVisible = 0
Dim Mark : Mark = 0
Dim MyHotkey : Set MyHotkey = Keyboard.RegisterHotkey("Control-Alt-Shift-I", 
"LaunchDialog")

Sub LaunchDialog()
If isVisible = 0 Then
Queue "DisplayDialog"
End If
End Sub

Sub DisplayDialog()
Dialog "DialogListViewFromScript.xml", "MyDialog1", "DialogEventHandler"
End Sub

Function DialogEventHandler(dObj, dEvent, dId, dControl)

DialogEventHandler = False

' Now we'll add items to the list view

If Mark < 1 Then

Dim NewLvItem
Set newLVItem = dObj.Control("listview1").NewItem
newLVItem.Text = "Aaron" 
newLVItem.Insert dObj.Control("listview1").Items.Count + 1
newLVItem.Text(1) = "Obsidian Blue"
newLVItem.Text(2) = "42"

Dim NewLvItem2
Set newLVItem2 = dObj.Control("listview1").NewItem
newLVItem2.Text = "Jeff" 
newLVItem2.Insert dObj.Control("listview1").Items.Count+1
newLVItem2.Text(1) = "Red"
newLVItem2.Text(2) = "97"

Dim NewLvItem3
Set newLVItem3 = dObj.Control("listview1").NewItem
newLVItem3.Text = "Doug" 
newLVItem3.Insert dObj.Control("listview1").Items.Count+1
newLVItem.Text(1) = "Orange"
newLVItem.Text(2) = "256"

Mark = Mark + 1
End If

' The first list view  items should be read as "Aaron, Favorite Color Obsidian 
Blue, Favorite Number 42." 

Select Case dId
Case "btn_ok"
If dEvent = buttonClicked Then
SpeakResult dObj, dEvent, dId, dControl
DialogEventHandler = True
Exit Function
End If

Case "btn_cancel"
If dEvent = buttonClicked Then
Speak "close"
Sleep 200

isVisible = 0
dObj.Close
DialogEventHandler = True
Exit Function
End If

Case Else
If dEvent = dialogCreated Then
isVisible = 1
DialogEventHandler = True
Exit Function
End If
End Select
End Function

Sub SpeakResult(dObj, dEvent, dId, dControl)
Dim textToSpeak

' for just first column text
' TextToSpeak = dObj.Control("listview1").Text 

' for entire row
TextToSpeak = dObj.Control("listview1").Text & " " & 
dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) 
Speak "You have chosen " & textToSpeak
End Sub

Here is the xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wescriptui>
<options>
<languageorder>
WE,OS,en-us
</languageorder>
</options>
<language id="en-us">

<dialog id="MyDialog1">
Dialog ListView
<group>
<group orientation="vertical">
<listview id="listview1" view="report">
<listviewcolumn>
Name
</listviewcolumn>
<listviewcolumn>
Favorite Color
</listviewcolumn>
<listviewcolumn>
Favorite Number
</listviewcolumn>
</listview>
</group>
<group>
<button id="btn_ok" system="ok" default="yes" widthclass="btn">
OK
</button>
<button id="btn_cancel" system="cancel" widthclass="btn" width="+10">
Close
</button>
</group>
</group>
</dialog>

</language>
</wescriptui>

Reply via email to