xBrowser array add/del elements

xBrowser array add/del elements

Postby Otto » Thu Mar 06, 2008 9:24 am

Hello Antonio,
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
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Postby nageswaragunupudi » Thu Mar 06, 2008 4:05 pm

Mr Otto

Do not use oBrw:SetArray after adding or deleting likes. Simply say Refresh
Regards

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

Popup in xBrowse

Postby ukoenig » Thu Mar 06, 2008 5:33 pm

Hello Otto,

I used that sample for a normal browse ( no Array )
You can find it at Topic => menu popup at....

Image

Regards
uwe :lol: [/img]
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Otto » Thu Mar 06, 2008 5:41 pm

Hello NageswaraRao,
thank you very much for you help.
All is working as suspected.
Regards,
Otto
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 57 guests