array browser delete issue

array browser delete issue

Postby Detlef » Fri Mar 11, 2022 5:01 pm

Dear All,
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
#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 ) } )
 
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: array browser delete issue

Postby artu01 » Fri Mar 11, 2022 5:57 pm

try
Code: Select all  Expand view

PROCEDURE delRow( oBrw, a )
//-------------------------
   MsgInfo( "deleting row # " + alltrim( str( oBrw:nArrayAt ) ) )
   oBrw:delete()
   //oBrw:Refresh()
RETURN
 
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: array browser delete issue

Postby Detlef » Fri Mar 11, 2022 7:56 pm

Thanks, artu01.
I tried but then nothing is deleted.
No effect on screen and the lenght of my array remains unchanged.
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: array browser delete issue

Postby FranciscoA » Fri Mar 11, 2022 8:06 pm

Detlef wrote:Dear All,
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
#include "FiveWin.ch"

PROCEDURE delRow( oBrw, a )
//-------------------------
   MsgInfo( "deleting row # " + alltrim( str( oBrw:nArrayAt ) ) )
   adel( a[ oBrw:nArrayAt], .t. )
   aSize( a, len( a ) - 1 )
   oBrw:Refresh()
RETURN

 


Intenta asi:
Try this way:
Code: Select all  Expand view
PROCEDURE delRow( oBrw, a )
//-------------------------
   MsgInfo( "deleting row # " + alltrim( str( oBrw:nArrayAt ) ) )
   adel( a, oBrw:nArrayAt, .t. )
oBrw:Refresh()
RETURN
 
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: array browser delete issue

Postby Detlef » Fri Mar 11, 2022 8:59 pm

Many thanks, Francisco.
I'm glad for your advice.
Now it's working okay.
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: wilsongamboa and 87 guests