xBrowser array add/del elements
Posted: Thu Mar 06, 2008 9:24 am
Hello Antonio,
How to prevent that after add a new element the header disappears.
Regrads,
Otto
How to prevent that after add a new element the header disappears.
Regrads,
Otto
Otto,
Here you have samples\mallorca.prg modified with your requirements. Right click on it to show a popup menu:
Code:
# INCLUDE "FiveWin.ch"
# INCLUDE "XBrowse.ch"
//-------------
FUNCTION Main()
//-------------
LOCAL oWnd,aLin:={},i,oBrw
FOR i:=1 TO 6
AAdd(aLin,{i,'Descripción '+Str(i)})
NEXT
DEFINE WINDOW oWnd
//--Definición Objeto TxBrowse
oBrw:=TxBrowse():New(oWnd)
oBrw:SetArray(aLin)
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:aCols[1]:cHeader := 'Cod'
oBrw:aCols[1]:cEditPicture := '@k 99'
oBrw:aCols[1]:bClrEdit := oBrw:bClrStd
oBrw:aCols[1]:bOnPostEdit := {|o,x| aLin[ oBrw:nArrayAt,1] := x }
oBrw:aCols[1]:nEditType := EDIT_GET
oBrw:aCols[1]:bEditValid := {|oGet| Valida( oGet ) } //<========
//--
oBrw:aCols[2]:cHeader := 'Descripción'
oBrw:aCols[2]:bClrEdit := oBrw:bClrStd
oBrw:aCols[2]:bOnPostEdit := {|o,x| aLin[ oBrw:nArrayAt,2] := x }
oBrw:aCols[2]:nEditType := EDIT_GET
//--
oBrw:CreateFromCode()
oBrw:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oBrw, aLin ) }
oWnd:oClient:=oBrw
ACTIVATE WINDOW oWnd
RETURN NIL
//-----------------------------------
STATIC FUNCTION Valida( oGet )
//-----------------------------------
LOCAL lValRet:=.T.
local bValid := oGet:bValid
local nVal := oGet:Value()
oGet:bValid = nil
IF nVal>6
// MsgAlert('No puede ser mayor que 6')
lValRet:=.f.
ENDIF
oGet:bValid = bValid
RETURN lValRet
function ShowPopup( nRow, nCol, oBrw, aLin )
local oMenu
MENU oMenu POPUP
MENUITEM "Add" ACTION ( AAdd( aLin, { AllTrim( Str( Len( aLin ) + 1 ) ), "New item" } ), oBrw:SetArray( aLin ), oBrw:Refresh() )
MENUITEM "Del" ACTION ( ADel( aLin, oBrw:nArrayAt ), ASize( aLin, Len( aLin ) - 1 ), oBrw:SetArray( aLin ), oBrw:Refresh() )
MENUITEM "Select" ACTION ( oBrw:GoTop(), oBrw:nArrayAt := 3, oBrw:Refresh() )
ENDMENU
ACTIVATE POPUP oMenu WINDOW oBrw AT nRow, nCol
return nil
_________________
regards, saludos
Antonio Linares
www.fivetechsoft.com