Page 1 of 1

[Solved] Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 9:32 am
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?

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 11:54 am
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:
https://forum.openoffice.org/en/forum/v ... 39&t=67677
https://forum.openoffice.org/en/forum/v ... 39&t=24299


Can you upload youe ODF type sample file here?

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 11:58 am
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.

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 12:04 pm
by Zizi64

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 12:53 pm
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)

https://forum.openoffice.org/en/forum/v ... 74&t=49294

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 8:57 pm
by Zizi64
I learned a useful thing again. Thank you Villeroy.

Listbox.ods
(12.03 KiB) Downloaded 54 times

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 9:33 pm
by Villeroy
Even simpler if you have MRI installed.
Select items and double-click the "Source" line in the MRI window.

Re: Check Item in Listbox is selected or not

PostPosted: Fri Jun 29, 2018 9:38 pm
by Zizi64
Even simpler if you have MRI installed.

I am using the Xray inspection tool.

Re: Check Item in Listbox is selected or not

PostPosted: Sun Jul 01, 2018 2:01 pm
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   Expand viewCollapse view
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