Page 1 of 1
SetMultiSelectCol() on line
Posted: Sat Apr 13, 2024 8:32 am
by Silvio.Falconi
I have an xbrowse created with an array without the :SetMultiSelectCol()
and I have the ability to display a menupopup like this
MENU oMenu POPUP
if oBrw:IsSelectedRow()
MENUITEM "Deselect the current row" action DeSelect_One_array(oBrw)
MENUITEM "Deselect everything" action oBrw:SelectRow( 0 )
MENUITEM "Prints the selected lines" action PrintBrowse(oParent:cCaption,oBrw,oDbf)
MENUITEM "Export the selected rows" action ExportToExcel(oBrw )
else //
MENUITEM "Select the current row" action oBrw:SelectRow( 2 )
MENUITEM "select all" action oBrw:SelectRow( 4 )
MENUITEM "Print " action NIL //PrintBrowse(oParent:cCaption,oBrw,oDbf)
....
Before making the selection, I would like to check whether SetMultiSelectCol() is activated in the xbrowse and if it has not been activated, activate it on first column before the selection. Obviously, when no records are selected, SetMultiSelectCol() must disappear
how can I implement this?
Re: SetMultiSelectCol() on line
Posted: Mon Apr 22, 2024 10:46 am
by Silvio.Falconi
Any solution ?
Re: SetMultiSelectCol() on line
Posted: Mon Apr 22, 2024 11:45 am
by Antonio Linares
Dear Silvio,
Could you please provide a small and self contained PRG example ?
thanks!
Re: SetMultiSelectCol() on line
Posted: Tue Apr 23, 2024 7:40 am
by Silvio.Falconi
Antonio Linares wrote:Dear Silvio,
Could you please provide a small and self contained PRG example ?
thanks!
this is a small sample
Code: Select all | Expand
#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "constant.ch"
// test array
Function test()
local oDlg,oFont,oBold
local oBrw,aBtnBrow:=array(3)
local adata:= { {"0001","aaaaaaaaaaaaaaa","00001"},; // Demo data
{"0001","bbbbbbbbbbbbbbb","00002"},;
{"0001","ccccccccccccccc","00003"},;
{"0001","ddddddddddddddd","00004"},;
{"0001","eeeeeeeeeeeeeee","00005"}}
local nBottom:= 8
local nRight := 55
local nHt := nBottom * DLG_CHARPIX_H
local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
local nRow:= 0,nCol:= 10
local nInterlinea := 30
oFont := TFont():New( "TAHOMA", 0, 16,, )
oBold := TFont():New( "TAHOMA", 0, 16,,.t. )
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
FONT oFont TiTle "test" COLOR CLR_BLACK, CLR_WHITE ;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
WS_MINIMIZEBOX)
@ nRow, 10 XBROWSE oBrw OF oDlg ;
COLUMNS 2;
HEADERS "Valore" ;
COLSIZES 310 ;
ARRAY aData ;
SIZE -10,-30 PIXEL STYLE FLAT NOBORDER
WITH OBJECT oBrw
:lDrawBorder := .t.
:lHScroll := .f.
:CreateFromCode()
END
@ oBrw:nBottom+2, 50 BTNBMP aBtnBrow[3] ;
RESOURCE "GRID_MNU", "", "", "" ;
SIZE 15, 13 PIXEL FLAT NOROUND GDIP OF oDlg ;
ACTION ::ShowPopUp( Contextual_Menu( Self,oBrw,oDlg ) )
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
aBtnBrow[3]:setsize(30, 26.2)
aBtnBrow[3]:nTop := oRect:nBottom-26
aBtnBrow[3]:nLeft := oRect:nWidth-36
RETURN nil
>
ACTIVATE DIALOG oDlg CENTER;
ON INIT oDlg:resize()
RETURN NIL
//------------------------------------------------------//
Function Contextual_Menu( Self,oBrw,oDlg )
local oMenu
MENU oMenu POPUP
if oBrw:IsSelectedRow()
MENUITEM "Deselect row" action DeSelect_One_array(oBrw)
MENUITEM "Deselect all" action oBrw:SelectRow( 0 )
MENUITEM "Print" action NIL
MENUITEM "Export" action NIL
else
MENUITEM "Select" action oBrw:SelectRow( 2 )
MENUITEM "Select all" action oBrw:SelectRow( 4 )
MENUITEM "Print" action NIL
MENUITEM "Export" action NIL
endif
ENDMENU
return oMenu
//------------------------------------------------------//
Function DeSelect_One_array(oBrw)
local nRecNo,nAt
nRecNo:=oBrw:nArrayAt
if ( nAt := AScan( oBrw:aSelected, nRecNo ) ) > 0
HB_ADel( oBrw:aSelected, nAt, .t. )
endif
oBrw:Refresh()
return nil
//----------------------------------------------------------//
Re: SetMultiSelectCol() on line
Posted: Tue Apr 23, 2024 5:22 pm
by Antonio Linares
Dear Silvio,
Have you reviewed samples\xbmulsel.prg ?
Re: SetMultiSelectCol() on line
Posted: Tue Apr 23, 2024 6:51 pm
by Silvio.Falconi
Antonio Linares wrote:Dear Silvio,
Have you reviewed samples\xbmulsel.prg ?
yes allready saw it
compile this test without :SetMultiSelectCol() you'll see this error
Error description: Error BASE/1005 No exported variable: LREADONLY
Args:
[ 1] = U
[ 2] = L .T.
Stack Calls
===========
Called from: xbmulsel.prg => _LREADONLY( 0 )
Called from: xbmulsel.prg => (b)MAIN( 38 )
Maybe I did not say it clear enough
I would like the procedure to check whether xbrowse has/does not have :SetMultiSelectCol()
if it does not have the :SetMultiSelectCol() the procedure must create the :SetMultiSelectCol() as the first column of the xbrowse and give the possibility to select the row
If there are no selected rows in the xbrowse the procedure must remove the :SetMultiSelectCol()
instead the test samples\xbmulsel.prg example already has the SetMultiSelectCol and the checkbox disables it but physically it is still in the xbrowse
I hope I was clear in my explanation