I have an xBrowse using an array.
Strange thing happens, when deleting a row.
If the last row is selected and I press the delete button, it's working fine.
If any other row is selected deleting doesn't work correctly.
Only the first column element of the row is deleted and the following column values shift to the left.
Please, can someone give me an advice to get this working?
- Code: Select all Expand view RUN
- #include "FiveWin.ch"
#include "xbrowse.ch"
FUNCTION Main()
//-------------
LOCAL oBrw, oDlg
LOCAL aData := CreateArray()
DEFINE DIALOG oDlg FROM 2,2 TO 24, 46 OF oDlg TITLE "Test Delete An Array Row"
@ 1.5, 1 XBROWSE oBrw OF oDlg ;
HEADERS "Name", "Interest", "Age " ;
SIZE 160, 135 ;
COLSIZES 100, 100, 80 ;
JUSTIFY AL_LEFT, AL_CENTER, AL_CENTER ;
ARRAY aData AUTOCOLS
oBrw:CreateFromCode()
@ 0.2, 1 BUTTON "&add" OF oDlg SIZE 30,12;
ACTION addRow( oBrw, aData )
@ 0.2, 8 BUTTON "&delete" OF oDlg SIZE 30,12 ;
ACTION delRow( oBrw, aData )
@ 0.2, 15 BUTTON "e&xit" OF oDlg SIZE 30,12 ;
ACTION oDlg:End()
ACTIVATE DIALOG oDlg ON INIT( oDlg:center() )
RETURN NIL
PROCEDURE addRow( oBrw, a )
//-------------------------
aadd( a, aMakePerson() )
oBrw:Refresh()
oBrw:GoBottom()
RETURN
PROCEDURE delRow( oBrw, a )
//-------------------------
MsgInfo( "deleting row # " + alltrim( str( oBrw:nArrayAt ) ) )
adel( a[ oBrw:nArrayAt], .t. )
aSize( a, len( a ) - 1 )
oBrw:Refresh()
RETURN
FUNCTION CreateArray()
//--------------------
LOCAL aRet := {}
LOCAL n
for n := 1 to 5
aadd( aRet, aMakePerson() )
next
RETURN( aRet )
FUNCTION aMakePerson()
//--------------------
LOCAL aInterest := { "Golf", "Football", "Knitting", "Singing", "Drinking" }
LOCAL aPeople := { "Jack", "Melissa", "Ernest", "George", "Melvin", "Brovira", "June", "Mike", "Penelope", "Stan", "Laurel" }
RETURN( { aPeople[ hb_RandomInt( 1, Len( aPeople ) ) ],;
aInterest[ hb_RandomInt( 1, Len( aInterest ) ) ],;
hb_RandomInt( 18, 100 ) } )