Sam Jones Posted March 19, 2018 Share Posted March 19, 2018 Is there a way to clear out a pull down menu in a dialog, so that one can populate the pull down with entirely new content? The code below does not seem to do the job. It would be nice if there was a command similar to the "vsoWidgetPopupClear" that is used for OIP pull downs GetChoiceCount(Dialog, kTargetData2BOList, fieldCount); IF fieldCount > 0 THEN BEGIN FOR index := 1 TO fieldCount DO BEGIN RemoveChoice(Dialog, kTargetData2BOList, index-1); END; END; {IF fieldCount > 0 } Quote Link to comment
MullinRJ Posted March 20, 2018 Share Posted March 20, 2018 Sam, It looks like your code should work. Have you verified that "fieldCount" is > 0? If it is, are your "Dialog" ID, and your "kTargetData2BOList" constant correct? I use something similar in Reshaper, where GetChoiceCnt is a custom function that returns the menu size from GetChoiceCount(), just like yours. for I := 0 to GetChoiceCnt(dlogID, MenuItem)-1 do RemoveChoice(dlogID, MenuItem, 0); HTH, Raymond Quote Link to comment
Julian Carr Posted March 20, 2018 Share Posted March 20, 2018 This works for me in many cases: FOR i := j DOWNTO 0 DO RemoveChoice(gDialog1, 29, i); Perhaps you need to go backwards? Julian 1 Quote Link to comment
MullinRJ Posted March 20, 2018 Share Posted March 20, 2018 Sam, After reading Julian's comment I looked at your code and mine again; there is a difference. I always remove the 0th element (the element at the front of the list). Julian's way removes the last element every time. You are removing the element at the index counter, which is a moving target. Eventually, the list gets shorter than the index counter and you will receive a runtime error. You need to pick one of our two methods and you should be okay to proceed. Raymond Quote Link to comment
DomC Posted February 27, 2022 Share Posted February 27, 2022 Hi Thanks @Julian. seems we need backward indexing for deleting the choices. 1 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.