Using Xlistbox in Base

I have been working my way through LibreOffice base and slowly learning how much different it is to MSAccess. It seems to me for my purposes that Xlistbox has useful additional methods compared with the standard listbox that comes in the default installation. I have searched the internet but cannot work out how to make a listbox an Xlistbox. I have seen things that say how it is a development of a standard listbox, lists of its methods and properties, and maybe I am stupid but I just can’t see how I start using it. Do I download a module that adds on to the standard interface, invoke it somehow in a Macro, or what?

XLIstox isn’t a special listbox for LibreOffice Base. You could use all the properties by the listbox directly or through macro coding: Api LibreOffice → XListBox.

What problem do you want to solve, which can’t be solved directly through the GUI?

Thank you for your quick response. I am really just trying out things and what I am trying to do is to read all the items in the list of a listbox. The list is created by an SQL and populates correctly. I want to use listbox.getitem(n) which is a method available in Xlistbox but the default listbox does not have this method. So this code:

OForm=ThisComponent.Drawpage.Forms.getByName(“Clients”)
oLbox=oForm.getbyname(“ClientSelect”)
j=oLbox.ItemCount 'this works. I get the correct count but the xlistbox method getitemcount() errors
k=1
do while k<j
mystring=oLbox.getitem(k) 'errors
do something with mystring
loop

So, I need to do something to make listbox.getitem(n) a method of my list box. The link you gave me I have visited many times and the only cryptic clue on that page is “Import XListBox.idl” . Obviously, I need my hand holding a bit!!!

If you could upload an example file, then together we would quickly figure out what’s going on.
And by the way, indexes in LO start from 0.

Ok, I have cut down the database file so it is one table and only the bits relating to it. So here it is attached
Example.odb (15.4 KB)

This is a common story. The variable oLbox supports the com.sun.star.awt.UnoControlListBoxModel service, not UnoControlListBox.
These objects are described in detail in the famous book by Andrew Pitonyak OOME_4_0.odt.

And: Use xray or mri to find the right properties you are looking for.
You will need something like

do while k < j
	mystring = oLbox.getitemText(k)
    k = k + 1
    …

Thank you RobertG that works, but now I want the other field in the list. The SQL generates 2 fields, the first one allows the client to be identified by a human, and the second is the ClientID. So in the listbox list you see things like “Mickey Mouse, 36 Disney Parade”, but when you pick it, you get the ClientID which is just a number. These ClientID’s will be in Surname order so are not sequential. Now, as I am reading down the list, the mystring=oLbox.getitemText(k) gives me the “Mickey Mouse, 36 Disney Parade”, but i would also like to be able to get the ClientID. so I need an oLbox.something(k) that gives me the ClientID. You have been brilliant so far, can you help me this time?

ClientID of the content, which has been shown, will be CurrentValue.

The complete list you will get with this:

do while k<j
	myString = oLbox.StringItemList(k)
	myValue = oLbox.ValueItemList(k)
	k = k + 1
	msgbox(myString & " → " & myValue)
loop

You will need to define myValue first, because you have set Option Explicit for macros.

To @Softlinksys

One hint for using this site: Use the speech bubble “comment” for your kind of contributions, as “answers” are reserved for solutions to the original question on “ask”-type sites.
.
Why not answer? The sequence of answers can be changed by upvoting, so the best “answer” should be on top after some time. But using answer in an discussion may loose the meaning, when the text you are answering to is no longer in front of your text.

RobertG you have been a star… What would be good is if a group of knowledgeable people like you could get together and assemble an appendix to the manual which listed the complete properties and methods of each control for use in writing Macros. I don’t believe that list exists anywhere on the internet. It would make life much easier for people to use Base for making small databases. (And big ones if you use a separate database engine.) I have been programming in Access for 30 years and it is the high quality of the documentation that is its strength. The fact that Windows is the only platform you can use it on is its weakness.

And Wanderer, I have just discovered the Comment thing, sorry if I was doing things wrong!

Have created a German Base Handbuch, which has been translated to English: Base Guide - ListBox
You couldn’t write down all the properties.
Best would be: Downlod Xray from here and let you show the properties of each element.

Yes I discovered the Base Guide but the three methods you have told me about in this thread are not there. I am not suggesting you do it, but wonder if some sort of open list could be created like a Wikipedia where people could put this information when they feel like it. I will try Xray and see how I do. I tried MRI but couldn’t work out what it was doing or how it helped me. Maybe I will be bugging you about Xray next Haha!!! In any case, I really want to thank you for your help.

Might be you didn’t found: See the link. There aren’t much properties shown, but ValueItemList and StringItemList are shown there.

But: Better will be: Download XRay and as again, if there are problems…

[Tutorial] Introduction into object inspection with MRI

I will have a look at that robleyd. At the moment I have got XRay at RobertG’s suggestion and have got that working. It certainly seems to me that you need one of them to do any substantial work in Base.