【发布时间】:2015-11-12 08:31:58
【问题描述】:
我在使用 OpenOffice.org ListBox 表单控件时遇到问题。 我已经构建了一个小表单(不是对话框),其中包含一个文本框、列表框和 2 个按钮。
Sub 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 :(
结束子
Sub 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
结束子
我非常感谢任何解决这个问题的方法!
【问题讨论】:
-
您的表单看起来像是 Word 文件 - 对吗?是否有任何基本文件连接到它?如您所见,列表框数组内容很笨重;如果表单连接到基本文件并且列表框内容由 SQL 字符串确定,则实际上更容易使用。如果有 Base 连接,最好将您的项目列表放在 Base 表中,按照表单用户输入的指示标记它们,然后
oListBox.refresh让它显示更新的列表。如果您只希望在 Word 中使用它 - 您的代码似乎可以正常工作,问题到底是什么?
标签: openoffice.org openoffice-writer listbox-control openoffice-base