Page 1 of 3

copy a row of xbrowse

PostPosted: Sat Dec 02, 2023 6:01 pm
by Silvio.Falconi
can I copy a row on a xbrowse and paste su another with same structure ?

Re: copy a row of xbrowse

PostPosted: Sat Dec 02, 2023 9:11 pm
by nageswaragunupudi
For this, define your browse and
Code: Select all  Expand view
oBrw:nEditTypes := EDIT_GET
oBrw:lCanPaste := .t.
oBrw:nMarqStyle := MARQSTYLE_HIGHLROWRC // or higher


Then go to the row you want to copy
Press ^C

Go to the row you want to paste
Go to the first column of the row // this is important
and then
Press ^V

Done.

Re: copy a row of xbrowse

PostPosted: Sun Dec 03, 2023 12:54 am
by Silvio.Falconi
Can i make It with a menu popup into xbrowse?
Wich are the commands

Re: copy a row of xbrowse

PostPosted: Sun Dec 03, 2023 6:21 pm
by nageswaragunupudi
METHOD-1: Using ClipBoard
--------------------------------
To copy the current row to ClipBoard
Code: Select all  Expand view
oBrw:Copy()


To Paste full row from ClipBoard
Code: Select all  Expand view
oBrw:GoLeftMost()
oBrw:Paste()


METHOD-2: Without using ClipBoard:
-----------------------------------------
To copy the current row to to memory
Code: Select all  Expand view
aCopy := oBrw:Values


To Paste full row from memory
Code: Select all  Expand view
oBrw:Lock()
oBrw:Values := aCopy
oBrw:Unlock( .t. )

Re: copy a row of xbrowse

PostPosted: Sun Dec 03, 2023 7:45 pm
by nageswaragunupudi
METHOD-1
Sample
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBar, oBrw, oFont, nCol

   USE CUSTOMER SHARED

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont
   DEFINE BUTTONBAR oBar SIZE 80,32 2010

   @ 50,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" AUTOCOLS LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :lCanPaste     := .t.
      :nMarqueeStyle := MARQSTYLE_HIGHLROW
      :bClrRowFocus  := { || { CLR_BLACK, RGB( 230,230,230 ) } }
      :bClrSelFocus  := { || { CLR_WHITE, CLR_BLUE } }
      :AddVar( "LCOPIED", .f. )
      :bPopUp        := { |oCol| PopMenu( oCol ) }
      //
      :CreateFromCode()
   END

   DEFINE BUTTON OF oBar PROMPT "Copy" ACTION ( ;
      oBrw:Copy(), oBrw:lCopied := .t., oBar:AEvalWhen(), ;
      oBrw:SetFocus() )
   DEFINE BUTTON OF oBar PROMPT "Paste" ACTION ( ;
      nCol := oBrw:nColSel, ;
      oBrw:GoLeftMost(), oBrw:Paste(), oBrw:lCopied := .f., ;
      oBrw:nColSel := nCol, ;
      oBar:AEvalWhen(), oBrw:SetFocus() ) ;
      WHEN oBrw:lCopied

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

function PopMenu( oCol )

   local oBrw  := oCol:oBrw
   local nCol
   local oPop

   MENU oPop POPUP 2010
      MENUITEM "Copy" ACTION ( oBrw:Copy(), oBrw:lCopied := .t., ;
         oBrw:oWnd:oBar:AEvalWhen() )
      MENUITEM "Paste" WHEN oBrw:lCopied ACTION ( ;
         nCol := oBrw:nColSel, ;
         oBrw:GoLeftMost(), oBrw:Paste(), oBrw:nColSel := nCol, ;
         oBrw:lCopied := .f., ;
         oBrw:oWnd:oBar:AEvalWhen(), oBrw:SetFocus() )
   ENDMENU

return oPop
 

Re: copy a row of xbrowse

PostPosted: Sun Dec 03, 2023 7:47 pm
by nageswaragunupudi
METHOD-2
Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBar, oBrw, oFont, nCol

   USE CUSTOMER SHARED VIA "DBFCDX"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont
   DEFINE BUTTONBAR oBar SIZE 80,32 2010

   @ 50,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" AUTOCOLS LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :lCanPaste     := .t.
      :nMarqueeStyle := MARQSTYLE_HIGHLROW
      :bClrRowFocus  := { || { CLR_BLACK, RGB( 230,230,230 ) } }
      :bClrSelFocus  := { || { CLR_WHITE, CLR_BLUE } }
      :AddVar( "ACOPY", nil )
      :bPopUp        := { |oCol| PopMenu( oCol ) }
      //
      :CreateFromCode()
   END

   DEFINE BUTTON OF oBar PROMPT "Copy" ACTION ( ;
      oBrw:aCopy := oBrw:Values, oBar:AEvalWhen(), ;
      oBrw:SetFocus() )
   DEFINE BUTTON OF oBar PROMPT "Paste" ACTION ( ;
      oBrw:Lock(), oBrw:Values := oBrw:aCopy, oBrw:Unlock( .t. ), ;
      oBrw:aCopy := nil, ;
      oBar:AEvalWhen(), oBrw:RefreshCurrent(), oBrw:SetFocus() ) ;
      WHEN !Empty( oBrw:aCopy )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

function PopMenu( oCol )

   local oBrw  := oCol:oBrw
   local nCol
   local oPop

   MENU oPop POPUP 2010
      MENUITEM "Copy" ACTION ( ;
      oBrw:aCopy := oBrw:Values, oBrw:oWnd:oBar:AEvalWhen(), ;
      oBrw:SetFocus() )

      MENUITEM "Paste" WHEN !Empty( oBrw:aCopy ) ACTION ( ;
      oBrw:Lock(), oBrw:Values := oBrw:aCopy, oBrw:Unlock( .t. ), ;
      oBrw:aCopy := nil, ;
      oBrw:oWnd:oBar:AEvalWhen(), oBrw:RefreshCurrent(), oBrw:SetFocus() )

   ENDMENU

return oPop
 

Re: copy a row of xbrowse

PostPosted: Sun Dec 03, 2023 7:49 pm
by nageswaragunupudi
METHOD-3:
USING DRAG AND DROP
Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBar, oBrw, oFont, oCur

   USE CUSTOMER SHARED VIA "DBFCDX"

   DEFINE CURSOR oCur DRAG
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont RESIZABLE

   @ 50,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" AUTOCOLS CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :oDragCursor   := oCur
      :bDragBegin    := { |r,c,f| SetDropInfo( oBrw:Values ) }
      :bDropOver     := < |u,r,c,f|
                          oBrw:SetPos( r, c, .t. )
                          oBrw:Lock()
                          oBrw:Values := u
                          oBrw:Unlock( .t. )
                          oBrw:RefreshCurrent()
                          return nil
                          >
      //
      :CreateFromCode()
   END


   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 

Re: copy a row of xbrowse

PostPosted: Mon Dec 04, 2023 9:04 am
by Silvio.Falconi
nageswaragunupudi wrote:METHOD-3:
USING DRAG AND DROP
Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBar, oBrw, oFont, oCur

   USE CUSTOMER SHARED VIA "DBFCDX"

   DEFINE CURSOR oCur DRAG
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont RESIZABLE

   @ 50,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" AUTOCOLS CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :oDragCursor   := oCur
      :bDragBegin    := { |r,c,f| SetDropInfo( oBrw:Values ) }
      :bDropOver     := < |u,r,c,f|
                          oBrw:SetPos( r, c, .t. )
                          oBrw:Lock()
                          oBrw:Values := u
                          oBrw:Unlock( .t. )
                          oBrw:RefreshCurrent()
                          return nil
                          >
      //
      :CreateFromCode()
   END


   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 




Thanks Rao but on my proocedure I have an array with multiselect

I have an array that has a "CodCep" field that is not displayed in xbrowse

Image

Code: Select all  Expand view
#include "fivewin.ch"



Function Main()

   Test("00001")
   Test("00002")
 retur nil

function Test(codcep)
   local oDlg, oBar, oBrw, oFont
   local aData:= {}

   //adata demo
      aAdd( aData, {codcep, 1.5,11,9,2 } )
      aAdd( aData, {codcep, 5.5,5,5,2.5,0.8 } )
      aAdd( aData, {codcep, 6.3,8,5,0.8 } )


   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont RESIZABLE

   @10,10 say "Computo:" +CodCep  SIZE 120,20 pixel OF oDlg

        @ 50,20 XBROWSE oBrw OF oDlg ;
              COLUMNS  2,3,4,5;
              HEADERS "Riga","Colonna","Larghezza","Altezza" ;
              COLSIZES 60,60,60,60 ;
              ARRAY aData     ;
              SIZE -20,-20 PIXEL   STYLE FLAT NOBORDER



   WITH OBJECT oBrw
       :SetMultiSelectCol()
               :lRecordSelector     := .t.
               :bRecSelHeader    := { || " Num. " }
               :bRecSelData      := { |o| Int( o:BookMark ) }
               :nRecSelWidth     := "999"
      :nEditTypes    := EDIT_GET
      :lCanPaste     := .t.
      :nMarqueeStyle := MARQSTYLE_HIGHLROW
      :bClrRowFocus  := { || { CLR_BLACK, RGB( 230,230,230 ) } }
      :bClrSelFocus  := { || { CLR_WHITE, CLR_BLUE } }
      :AddVar( "ACOPY", nil )
      :bPopUp        := { |oCol| PopMenu( oCol ) }
      //
      :CreateFromCode()
   END
ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   return nil


function PopMenu( oCol )

   local oBrw  := oCol:oBrw
   local nCol
   local oPop

   MENU oPop POPUP 2010
   MENUITEM "Copy" ACTION ( ;
      oBrw:aCopy := oBrw:Values, ;
      oBrw:SetFocus() )

      MENUITEM "Paste" WHEN !Empty( oBrw:aCopy ) ACTION ( ;
      oBrw:Lock(), oBrw:Values := oBrw:aCopy, oBrw:Unlock( .t. ), ;
      oBrw:aCopy := nil, ;
      oBrw:RefreshCurrent(), oBrw:SetFocus() )
   ENDMENU

return oPop

 





the user open a dialog sample Test("00001")
when the user click on Multiselect one record or more records the procedure must show the menu (copy/paste)

then the use close the dialog and open another with another codcep Test("00002")

and can paste the record or the records copied ( "00001") and create new record or new records

but it must change the field codcep into new codcep ( "00002")


how I can make ?

Re: copy a row of xbrowse

PostPosted: Mon Dec 04, 2023 2:03 pm
by Otto
Silvio,

Interesting, I just worked on the same problem in mod harbour. Actually, the solution is exactly the same as with Fivewin. You copy the row as an array (object) and insert it in the 2nd browser.

Although it is not welcome here, I post. I think we all have to prepare for the future, and the future is on the web. Unless we only have 6 months left until retirement.

But you should not be selfish either. Many of us want to stay in the market for longer.

Best regards,
Otto

BTW, do you know the FIVEWIN functions for mod harbour? For example: MH_ArrayToHTML() , H_ValToHTML( ) from Mr. RAo?
Similar to xbrowser.





Image

Re: copy a row of xbrowse

PostPosted: Mon Dec 04, 2023 3:10 pm
by Silvio.Falconi
Otto wrote:Silvio,

Interesting, I just worked on the same problem in mod harbour. Actually, the solution is exactly the same as with Fivewin. You copy the row as an array (object) and insert it in the 2nd browser.

Although it is not welcome here, I post. I think we all have to prepare for the future, and the future is on the web. Unless we only have 6 months left until retirement.

But you should not be selfish either. Many of us want to stay in the market for longer.

Best regards,
Otto

BTW, do you know the FIVEWIN functions for mod harbour? For example: MH_ArrayToHTML() , H_ValToHTML( ) from Mr. RAo?
Similar to xbrowser.





Image


Not web!!!
I ask a questioni ti nages please

Re: copy a row of xbrowse

PostPosted: Mon Dec 04, 2023 6:03 pm
by nageswaragunupudi
do not use oBrw:aCopy

Keep a variable aCopy

For copying
Code: Select all  Expand view
aCopy := oBrw:aRow


For pasting
Code: Select all  Expand view
aCopy[ 1 ] := codsep
oBrw:aArrayData[ oBrw:nArrayAt ] := aCopy

Re: copy a row of xbrowse

PostPosted: Mon Dec 04, 2023 6:07 pm
by Silvio.Falconi
nageswaragunupudi wrote:do not use oBrw:aCopy

Keep a variable aCopy

For copying
Code: Select all  Expand view
aCopy := oBrw:aRow


For pasting
Code: Select all  Expand view
aCopy[ 1 ] := codsep
oBrw:aArrayData[ oBrw:nArrayAt ] := aCopy

Sorry,
I'am not understading
where i must inserti these Lines on my test (up)
Thanks

Re: copy a row of xbrowse

PostPosted: Tue Dec 05, 2023 7:44 am
by Silvio.Falconi
Nages

I go to the first xbrowse
I show the popup menu
there are two options "Copy" and "Paste" but the second option should not be displayed because the record has not yet been saved in the acopy variable

I copy a record from the first xbrowse with the "copy" option

I go to the second xbrowse
I paste

when I view the popup menu the "copy" option is always disabled while it should be re-enabled after copying


Code: Select all  Expand view


#include "fivewin.ch"

 static aCopy

Function Main()

   Test("00001")
   Test("00002")
 retur nil

function Test(codcep)
   local oDlg, oBar, oBrw, oFont
   local aData:= {}

   //adata demo
      aAdd( aData, {codcep, 1.5,11,9,2 } )
      aAdd( aData, {codcep, 5.5,5,5,2.5,0.8 } )
      aAdd( aData, {codcep, 6.3,8,5,0.8 } )


   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont RESIZABLE

   @10,10 say "Computo:" +CodCep  SIZE 120,20 pixel OF oDlg

        @ 50,20 XBROWSE oBrw OF oDlg ;
              COLUMNS  2,3,4,5;
              HEADERS "Riga","Colonna","Larghezza","Altezza" ;
              COLSIZES 60,60,60,60 ;
              ARRAY aData     ;
              SIZE -20,-20 PIXEL   STYLE FLAT NOBORDER



   WITH OBJECT oBrw
      :SetMultiSelectCol()

               :lRecordSelector     := .t.
               :bRecSelHeader    := { || " Num. " }
               :bRecSelData      := { |o| Int( o:BookMark ) }
               :nRecSelWidth     := "999"

      :nEditTypes    := EDIT_GET
      :lCanPaste     := .t.
      :nMarqueeStyle := MARQSTYLE_HIGHLROW
      :bClrRowFocus  := { || { CLR_BLACK, RGB( 230,230,230 ) } }
      :bClrSelFocus  := { || { CLR_WHITE, CLR_BLUE } }


      :bPopUp        := { |oCol| PopMenu( oCol, oBrw:aArrayData[ oBrw:nArrayAt ][1] ) }
      //
      :CreateFromCode()
   END
ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   return nil


function PopMenu( oCol, codsep )

   local oBrw  := oCol:oBrw
   local nCol
   local oPop

MENU oPop POPUP 2010
      MENUITEM "Copy" WHEN acopy=NIL ACTION ( aCopy := oBrw:aRow,;
      oBrw:SetFocus() )
      MENUITEM "Paste" ACTION ( ;
      oBrw:Lock(), ;
      aCopy[ 1 ] := codsep ,;
      aadd( oBrw:aArrayData,aCopy ),; // oBrw:aArrayData[ oBrw:nArrayAt ] := aCopy ,;
      oBrw:Unlock( .t. ), ;
      oBrw:RefreshCurrent(),aCopy:= {}, oBrw:SetFocus() )
   ENDMENU

   return oPop


 




Image

Re: copy a row of xbrowse

PostPosted: Tue Dec 05, 2023 8:12 am
by Otto
Silvio,
try this:


Code: Select all  Expand view
 MENUITEM "Paste" WHEN acopy!=NIL ACTION ( ;
          oBrw:Lock(), ;
          aCopy[ 1 ] := codsep ,;
          aadd( oBrw:aArrayData,aCopy ),; // oBrw:aArrayData[ oBrw:nArrayAt ] := aCopy ,;
          oBrw:Unlock( .t. ), ;
          oBrw:RefreshCurrent(), oBrw:SetFocus(), acopy:=NIL )
         

Re: copy a row of xbrowse

PostPosted: Tue Dec 05, 2023 8:14 am
by Silvio.Falconi
Otto wrote:Silvio,
try this:


Code: Select all  Expand view
 MENUITEM "Paste" WHEN acopy!=NIL ACTION ( ;
          oBrw:Lock(), ;
          aCopy[ 1 ] := codsep ,;
          aadd( oBrw:aArrayData,aCopy ),; // oBrw:aArrayData[ oBrw:nArrayAt ] := aCopy ,;
          oBrw:Unlock( .t. ), ;
          oBrw:RefreshCurrent(), oBrw:SetFocus(), acopy:=NIL )
         



it is the same
please see the video