Jayme McColgan Posted April 2, 2023 Share Posted April 2, 2023 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) Quote Link to comment
MullinRJ Posted April 2, 2023 Share Posted April 2, 2023 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 1 Quote Link to comment
Jayme McColgan Posted April 5, 2023 Author Share Posted April 5, 2023 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 1 Quote Link to comment
MullinRJ Posted April 5, 2023 Share Posted April 5, 2023 @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 Quote Link to comment
Recommended Posts
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.