How do i populate a listbox depending on values from another listbox

Hi, I’m working on a calc-project.
I would like to create a dialog with two listboxes. Listbox1 is master of Listbox2. Everytime when I click on an element i Listbox 1 I want Listbox 2 to populate with elements belonging to the selected item.

Well my question is who to start this process. The eventhandler of the listbox has some events which I perhaps can use, (there are an event called “Elementstatus endret” (norweginan - something like Elementstate changed (?) ). But still … If I connect this event to a procedure or function, I have to reach the running dialogbox from thant procedure. Where/how do I find the handle for this dialog? Or perhaps there is a better way…

Regards
Harald

Welcome Harald! Where will your listboxes get data from? From the cells in a sheet? List of constants? Do you want to make sure to do it in a dialogue? It is possible to make an input form directly in the sheet of the spreadsheet - it’s a little easier

Hi, yes both get data from cells in two different sheets. I know I can do it another way, but you know… curious :-). I looked at the event object for the listbox but as far as i could see there was no parent-object, or handler to the parent.

Hello,

This can be a large task if you have little to no experience with macros. Dialogs need macros.

There are many samples posted on the Ask site regarding dialogs. With a dialog, the object should be a global variable. With that you can access after creation.

As for the list boxes, yes, Item status changed can work. When activated the module called should read the selected item and the you can fill the second list box based upon that selection.

Here is a link to an answer containing other links regarding dialogs → how can i set DesktopAsParent for a dialog in a library?

Please understand that this is a question and answer site and not a forum. Your question is very general in nature and needs to be more of a specific nature.

“Please understand that this is a question and answer site and not a forum.” Ok. Sorry.

this thread is quite old but
there is an Example

wich contains also the link to this topic