copy a row of xbrowse

copy a row of xbrowse

Postby Silvio.Falconi » Sat Dec 02, 2023 6:01 pm

can I copy a row on a xbrowse and paste su another with same structure ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby nageswaragunupudi » Sat Dec 02, 2023 9:11 pm

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: copy a row of xbrowse

Postby Silvio.Falconi » Sun Dec 03, 2023 12:54 am

Can i make It with a menu popup into xbrowse?
Wich are the commands
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby nageswaragunupudi » Sun Dec 03, 2023 6:21 pm

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. )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: copy a row of xbrowse

Postby nageswaragunupudi » Sun Dec 03, 2023 7:45 pm

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: copy a row of xbrowse

Postby nageswaragunupudi » Sun Dec 03, 2023 7:47 pm

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: copy a row of xbrowse

Postby nageswaragunupudi » Sun Dec 03, 2023 7:49 pm

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: copy a row of xbrowse

Postby Silvio.Falconi » Mon Dec 04, 2023 9:04 am

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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Otto » Mon Dec 04, 2023 2:03 pm

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
Last edited by Otto on Mon Dec 04, 2023 3:18 pm, edited 1 time in total.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Mon Dec 04, 2023 3:10 pm

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby nageswaragunupudi » Mon Dec 04, 2023 6:03 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: copy a row of xbrowse

Postby Silvio.Falconi » Mon Dec 04, 2023 6:07 pm

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Tue Dec 05, 2023 7:44 am

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
Last edited by Silvio.Falconi on Tue Dec 05, 2023 8:17 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Otto » Tue Dec 05, 2023 8:12 am

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 )
         
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Tue Dec 05, 2023 8:14 am

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests