Page 2 of 2

Re: Combobox refresh

Posted: Sun Nov 20, 2016 12:59 pm
by serge_girard
Thanks Theo !
Serge

Re: Combobox refresh

Posted: Sun Nov 20, 2016 2:35 pm
by Rathinagiri
Thanks.

Why do you use asort() after the combobox refresh?

Re: Combobox refresh

Posted: Sun Nov 20, 2016 3:03 pm
by trmpluym
Rathinagiri wrote:Thanks.

Why do you use asort() after the combobox refresh?
Rathi, it should be in front (because i like my Comboboxes sorted). Thanks for keeping me sharp :D

Code: Select all

FUNCTION RefreshCombobox(cWindowName,cComboBoxName,aArrayName)

LOCAL nX

DoMethod(cWindowName,cComboBoxName,'DeleteAllItems') 

aSort(aArrayName)

FOR nX = 1 TO LEN(aArrayName)
   DoMethod(cWindowName,cComboBoxName,'AddItem',aArrayName[nX]) 
NEXT

Return

Re: Combobox refresh

Posted: Sun Nov 20, 2016 4:18 pm
by Rathinagiri
There is already a feature in combobox - 'Sort' enabled. It is automatically sorted even if you enter in different order.

Just FYI.

Re: Combobox refresh

Posted: Sun Nov 20, 2016 7:55 pm
by trmpluym
Thanks Rathi !

Re: Combobox refresh

Posted: Mon Nov 21, 2016 12:46 am
by jairpinho
Thank you, it worked.


trmpluym wrote:I created a small universal function for the refresh of a ComboBox with a one dimensional array source.

It is simple but maybe it can help some others :)

Code: Select all

FUNCTION RefreshCombobox(cWindowName,cComboBoxName,aArrayName)

LOCAL nX

DoMethod(cWindowName,cComboBoxName,'DeleteAllItems') 

FOR nX = 1 TO LEN(aArrayName)
   DoMethod(cWindowName,cComboBoxName,'AddItem',aArrayName[nX]) 
NEXT

aSort(aArrayName)

Return