Hi All -
Totally new to OOo, so please forgive me if this is pretty easy (I come from a VBA background) ... I have a form set up in Base where whenever someone changes a particular combo box (cbx_account), it automatically updates a separate list box with new entries (lbx_lines). The problem is, I want all the items in the new list box selected by default but only one item is usually selected. Furthermore, this wouldn't be such a big problem except whenever I manually select all the items and then go to click on the "submit" button (a button I created as part of the form), it deselects the last item I had just selected and so it looks like (to the macro executed when the submit button is clicked) I didn't select all of them when I did!
If I could figure out a way to just automatically select all the items in the list box by default (i.e., via basic code) that would hopefully solve my problem. -Most- of the time (eg, maybe 95%) the user will want every item selected anyway, so doing this would also alleviate some work on their end as well.
Any ideas are greatly appreciated! Thanks,
Kevin
[Solved] List Box - Select Items
[Solved] List Box - Select Items
Last edited by ktr73 on Thu Jun 26, 2008 9:33 pm, edited 1 time in total.
OOo 2.4.X on Ubuntu 8.x + Windows XP
Re: List Box - Select Items
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: List Box - Select Items
Hey -
That didn't seem to work (my list box provided an interface for OListBoxModel as opposed to XListBox, which is where the link pointed to). But it lead me to: http://www.oooforum.org/forum/viewtopic.phtml?t=67724, which in turn gave me the idea for the following code:
And that seems to work! All the items are selected by default when running this code. Thanks for your help!
Kevin
That didn't seem to work (my list box provided an interface for OListBoxModel as opposed to XListBox, which is where the link pointed to). But it lead me to: http://www.oooforum.org/forum/viewtopic.phtml?t=67724, which in turn gave me the idea for the following code:
Code: Select all
Dim selections(Ubound(lbx_lines.StringItemList)) As Integer
For i = 0 To Ubound(lbx_lines.StringItemList)
selections(i) = i
Next i
lbx_lines.SelectedItems = selections
Kevin
OOo 2.4.X on Ubuntu 8.x + Windows XP
Re: [Solved] List Box - Select Items
The model reflects the same properties you can set in the dialog designer. The running dialog has "living" controls.
The model: http://api.openoffice.org/docs/common/r ... Model.html
The living thing derived from a model: http://api.openoffice.org/docs/common/r ... stBox.html
OK, this is not a perfect example. I would set the model's default selection before loading. But this makes more sense:
The model: http://api.openoffice.org/docs/common/r ... Model.html
The living thing derived from a model: http://api.openoffice.org/docs/common/r ... stBox.html
Code: Select all
Sub run_Dialog1
oLib = DialogLibraries.Standard
Dlg = CreateUnoDialog(oLib.getByName("Dialog1"))
Dlg.setVisible(True)
REM now we have a visible window with controls
oCtrl = Dlg.getControl("ListBox")
oCtrl.selectItemPos(0)
Dlg.execute
End Sub
Code: Select all
sub someEvent(oEv)
caller = oEv.Source 'some other control
dlg = caller.getContext()
list = dlg.getControl("ListBox3")
list.selectItemPos(0)
end Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice