[Solved] Check Item in Listbox is selected or not

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
MINTHETNAUNG
Posts: 18
Joined: Mon Jun 18, 2018 3:33 am

[Solved] Check Item in Listbox is selected or not

Post by MINTHETNAUNG »

Hi guys, I have got one Listbox A with several items inside. It is in multi-selection mode. A user can select one or more items from it. When a user does, I want those selected items to appear inside another Listbox B. How can I do that with Macro in Calc Dialog Listbox?
Last edited by MINTHETNAUNG on Mon Jul 09, 2018 9:04 am, edited 1 time in total.
Openoffice 4.1.5 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Check Item in Listbox is selected or not

Post by Zizi64 »

I have got one Listbox A with several items inside. It is in multi-selection mode.
If I know it exactly, there is not multiselection mode Listbox feature in the Apache OpenOffice and LibreOffice Calc...

Here are a similar topics:
viewtopic.php?f=39&t=67677
viewtopic.php?f=39&t=24299


Can you upload youe ODF type sample file here?
Last edited by Zizi64 on Fri Jun 29, 2018 12:00 pm, edited 2 times in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Check Item in Listbox is selected or not

Post by Villeroy »

Install the MRI extension
Point a list box event to macro:My_Macros>MriLib>Module1>Mri
If I know it exactly, there is not multiselection mode Listbox feature in the Apache OpenOffice and LibreOffice Calc...
Listbox have a multi-selection property. You can use it without value binding.
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
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Check Item in Listbox is selected or not

Post by Zizi64 »

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Check Item in Listbox is selected or not

Post by Villeroy »

Zizi64 wrote:I found a short description:
https://wiki.openoffice.org/wiki/Docume ... I/List_Box
That page describes the model of a lits box.
Calling MRI from the loaded list box object, you get methods get/setSelectedItemsPos and get/setSelectedItems (aka pseudo-properties SelectedItemsPos and SelectedItems)

viewtopic.php?f=74&t=49294
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
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Check Item in Listbox is selected or not

Post by Zizi64 »

I learned a useful thing again. Thank you Villeroy.
Listbox.ods
(12.03 KiB) Downloaded 186 times
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Check Item in Listbox is selected or not

Post by Villeroy »

Even simpler if you have MRI installed.
Select items and double-click the "Source" line in the MRI window.
Attachments
multiselect.odt
(8.97 KiB) Downloaded 159 times
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
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Check Item in Listbox is selected or not

Post by Zizi64 »

Even simpler if you have MRI installed.
I am using the Xray inspection tool.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Check Item in Listbox is selected or not

Post by Villeroy »

Write a Basic wrapper just like the MRI wrapper.
When I used Xray, I had this one which can inspect the elements of an array:

Code: Select all

Sub myXRay(optional v)
Dim i%,obj,x%,sRec$
Static iRec%
if ismissing(v) then v = ThisComponent
	globalscope.basiclibraries.loadlibrary("XrayTool")
	if isarray(v) then
		iRec = iRec +1
		for i = lBound(v) to uBound(v)
			obj = v(i)
			myXRay obj 'recursive for nested arrays
			if (i< uBound(v)) then 
				If iRec > 1 then sRec$ = "[Recursion="& iRec &"] " : else sRec =""
				x = msgbox(sRec & i -lBound(v)+2 &" / "& uBound(v) - lBound(v) +1,5,"X-ARRAY")
				if x = 2 then exit for
			endif
		next
		iRec = iRec -1
	else
		xray v
	end if
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
Post Reply