FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Adding an Element to a Combobox array
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Adding an Element to a Combobox array

Posted: Fri Jul 20, 2012 09:14 PM
To All

I have an array that is created from a table and I use that array as the pick list from a combobox

Code (fw): Select all Collapse
aBin := {}

oRsBin:MoveFirst()
Do While .not. oRsBin:eof

   cName := oRsBin:Fields("Bin"):Value
   AAdd( aBin, cName )
   oRsBin:MoveNext()

End Do

oRsBin:CLose()
oRsBin := NIL

...
...

 REDEFINE COMBOBOX oBin  var cBin         ID 171 of oInvt  ;
            ITEMS aBin UPDATE


I have a side button function that adds a new record to the table then adds that new element to the passed array ( by reference ) .

Code (fw): Select all Collapse
REDEFINE BTNBMP oBTN10 ID 153 of oInvt  ;     // add bin
            PROMPT "Add" CENTER 2007;
            ACTION ( _BinView( "A", "", "INV", @aBin, @cBin, oBin ))


Code (fw): Select all Collapse
FUNC _BinView( cMODE, oRsBin, cFrom, aBin, cBin, oBin )

...
...
ACTIVATE DIALOG oUSERS // modal dialog


If cFrom = "INV" .and. cMode = "A"
 *  xbrowse( abin )

   cName := oRsBin:Fields("Bin"):Value
   msginfo( cName )

   AAdd( aBin, cName )
   oRsBin:CLose()

   cBin := cName
   oBin:ReFresh()

 *  xbrowse( abin )
ENdif

lOK1 := lOK

RETURN( lOK1 )


As I have tested .. the passed array is being appended as it was passed by reference .. but the list of values ( aBin array ) does not change when I go back and pull down the list in the Combobox.

As you can see .. I am trying to Refresh all the objects but when I return to the combobox .. aBin is not updated with my new record.

Obviously this has something to do with updating the aBin variable on the Combobox .. any help would be appreciated.

Rick Lipkin
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Adding an Element to a Combobox array

Posted: Fri Jul 20, 2012 10:04 PM

Rick, try using oCbx:SetItems( aBin ) method.

EMG

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: Adding an Element to a Combobox array

Posted: Sat Jul 21, 2012 01:56 PM

Enrico

Thank you! Worked great

Rick Lipkin

Continue the discussion