我在使用 OpenOffice.org ListBox 表单控件时遇到问题。我已经构建了一个包含文本框和 ListBox 以及 2 个按钮的小表单(不是对话框)。
子 AddToList_ButtonClicked()
Dim oThisDoc As Object
Dim oForms as Object
Dim oForm as Object
oThisDoc = thisComponent.getDrawPage()
oForms = oThisDoc.getForms()
oForm = oForms.getByName("SimpleForm")
Dim oTextBox As Object
Dim oListBox As Object
oListBox = oForm.getByName("simpleListBox")
oTextBox = oForm.getByName("simpleTextBox").Text
oListBox.stringitemlist() = Array("One", "Two", "Three") '<--- Only possible way to add items to the ListBox Form Control :(
结束子
子 RemoveFromList_ButtonClicked()
Dim oThisDoc As Object
Dim oForms as Object
Dim oForm as Object
oThisDoc = thisComponent.getDrawPage()
oForms = oThisDoc.getForms()
oForm = oForms.getByName("SimpleForm")
Dim oListBox As Object
oListBox = oForm.getByName("simpleListBox")
oListBox.stringitemlist() '<--- contains array of items
oListBox.SelectedItems '<--- contains items selected for removal
结束子
我非常感谢这个问题的任何解决方案!