Jump to content

Populating a dropdown based on another dropdown.


Recommended Posts

hey everyone,

 

I'm having some trouble in my dialog with populating a dropdown based on another dropdown. i can't figure out how to properly clear the list and repopulate it with the new data... it always seems to leave behind something from the previous list. i've tried various combination of vs.SelectChoice()vs.RemoveChoice(), and vs.AddChoice(). 

 

here's my current iteration... 

 

def Dialog_Handler4(item ,data):
  if item == 33:
    for i in range(vs.GetChoiceCount(dialog1, 36)):
    	vs.RemoveChoice(dialog1, 36, i)

    for j in range(len(formattted_labels[data][2])):
      vs.AddChoice(dialog1, 36, formattted_labels[data][2][j], j)

 

Link to comment
On 4/1/2023 at 11:53 PM, MullinRJ said:

Hi @Jayme McColgan,

 

   The easiest way is to delete the first (0th) element N times. Your code is moving up the list as your list is shrinking, so yes, there will be residual entries left over.

 

Try:

for i in range(vs.GetChoiceCount(dialog1, 36)): 
      vs.RemoveChoice(dialog1, 36, 0)

 

Raymond

 

omg that worked... lol man that really should be a note on the VS reference page for vs.RemoveChoice() lol

  • Love 1
Link to comment

@Jayme McColgan,  LOL – Love the enthusiasm of your reply! 

 

A note at this point would only benefit other people. I'm pretty sure you will never need that example again 😉, but I'll add a note soon.

 

If you are using the HTML version of the script reference, a user's note will not show up. I can only add one to the online Developer WIKI. FYI

 

Glad I could help,

Raymond

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...