Adding an Element to a Combobox array

Adding an Element to a Combobox array

Postby Rick Lipkin » Fri Jul 20, 2012 9: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: Select all  Expand view

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: Select all  Expand view

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


Code: Select all  Expand view


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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Adding an Element to a Combobox array

Postby Enrico Maria Giordano » Fri Jul 20, 2012 10:04 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Adding an Element to a Combobox array

Postby Rick Lipkin » Sat Jul 21, 2012 1:56 pm

Enrico

Thank you! Worked great

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests