Page 1 of 1

Edit cell on xbrowse

Posted: Mon Oct 28, 2024 6:26 pm
by Silvio.Falconi
on a xbrowse I use

Image


:nEditTypes := EDIT_GET

the user can insert numbers But I wish the use can insert only number of two digit from 1 to 90

How I can resolve ?

Re: Edit cell on xbrowse

Posted: Mon Oct 28, 2024 11:16 pm
by cmsoft
Puedes usar bEditValid

Code: Select all | Expand

:bEditValid :=  {| oGet | if(oGet:value > 0 .and. oGet:value < 91,.t.,(MsgInfo("Solo 0 a 90"),.f.)) }

Re: Edit cell on xbrowse

Posted: Tue Oct 29, 2024 7:13 am
by Silvio.Falconi
cmsoft wrote:Puedes usar bEditValid

Code: Select all | Expand

:bEditValid :=  {| oGet | if(oGet:value > 0 .and. oGet:value < 91,.t.,(MsgInfo("Solo 0 a 90"),.f.)) }


Not Work

Image

I made

@ 80, 10 XBROWSE oBrw SIZE 455,oDlg:nBottom-200 PIXEL OF oDlg ;
DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

SetupBrowseMatrix(oBrw)
oBrw:RecSelShowKeyNo()
oBrw:CreateFromCode()

static function SetupBrowseMatrix( oBrw )

WITH OBJECT oBrw
// :RecSelShowKeyNo()

AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )
:bEditValid := {| oGet | if(oGet:value > 0 .and. oGet:value < 91,.t.,(MsgInfo("Solo 0 a 90"),.f.)) }
:nEditTypes := EDIT_GET
:nWidths := 24
:lDrawBorder := .t.


....


END

Re: Edit cell on xbrowse

Posted: Tue Oct 29, 2024 7:18 am
by Silvio.Falconi
perhaps ...

Code: Select all | Expand

For n=1 to  len(oBrw:aCols)
        oBrw:aCols[n]:bEditValid :=  {| oGet | if(oGet:value >= 0 .and. oGet:value < 91,.t.,;
                         (MsgInfo("Solo da 0  a 90"),.f.)) }
      END
But it must erase the edit

Re: Edit cell on xbrowse

Posted: Tue Oct 29, 2024 12:18 pm
by cmsoft
bEditValid es un metodo de la clase TXBrwColumn no de la clase TXBrowse
Debes ponerlo a cada columna que desees

Re: Edit cell on xbrowse

Posted: Tue Oct 29, 2024 9:37 pm
by nageswaragunupudi
But it must erase the edit
Please try this alternative

Code: Select all | Expand

#include "fivewin.ch"

function Main()

   local aData := Array( 10, 10 )

   AEval( aData, { |aRow| AFill( aRow, 0 ) } )

   XBROWSER aData FASTEDIT SHOW RECID SETUP ( ;
      oBrw:bEditValues := { |x,o| If( x == nil, o:oBrw:aRow[ o:nCreationOrder ], ;
         If( x >= 0 .and. x < 91, o:oBrw:aRow[ o:nCreationOrder ] := x, nil ) ) }, ;
      oBrw:cEditPictures := "@Z 99" ;
      )

return nil