Colegas, necesito hacer una búsqueda en un tree y no tengo idea como empezar. He buscado en el foro pero no encontré nada. Alguien tiene idea ? Muchísimas gracias.
Saludos
METHOD Scan( bAction ) CLASS TTreeView
return ScanItemsBlock( ::aItems, bAction )
static function ScanItemsBlock( aItems, bAction )
local oItem, n := 1, nResult := 0
while n <= Len( aItems ) .and. nResult == 0
oItem = aItems[ n ]
if Eval( bAction, oItem )
return n
else
if Len( oItem:aItems ) > 0
nResult = ScanItemsBlock( oItem:aItems, bAction )
endif
endif
n++
end
return nResult
MsgInfo( oTree:Scan( { | o | cText $ o:cPrompt } ) )
METHOD Scan( bAction ) CLASS TTreeView
return ScanItemsBlock( ::aItems, bAction )
static function ScanItemsBlock( aItems, bAction )
local oItem, n := 1, oItemFound
while n <= Len( aItems ) .and. oItemFound == nil
oItem = aItems[ n ]
if Eval( bAction, oItem )
return oItem
else
if Len( oItem:aItems ) > 0
oItemFound = ScanItemsBlock( oItem:aItems, bAction )
endif
endif
n++
end
return oItemFound
function SearchTextInTree( oTreeView, cText )
local oItem := oTreeView:Scan( { | o | cText $ o:cPrompt } )
if oItem != nil
MsgInfo( oItem:cPrompt )
endif
return nil
#include 'fivewin.ch'
#include 'xbrowse.ch'
Static oWnd
Static oTree
Static aCursos
Static aAlumnos
Static aSecciones
//----------------------------------------------------------------------------//
Function Main()
DefineEntorno()
BuscaLosAlumnos()
Define Window oWnd MDI
Activate Window oWnd Maximized On Init TablaAlumnos()
Return 0
//----------------------------------------------------------------------------//
Function TablaAlumnos()
Local i
Local oFont1
Local oFont2
Local oFont3
Local oFont4
Local oBrwCargaA
Local oWndAlumnos
Define Font oFont1 Name "Segoe UI Light" Size 0, -12 Bold
Define Font oFont2 Name "Segoe UI Light" Size 0, -12
Define Font oFont3 Name "Segoe UI" Size 0, -14
Define Font oFont4 Name "Segoe UI" Size 0, -14 Bold
Define Window oWndAlumnos MDICHILD Of oWnd No Caption Border None Color 0, CLR_WHITE
@ 0, 0 xBrowse oBrwCargaA Of oWndAlumnos Size 300, 470 Noborder
oBrwCargaA : SetTree( oTree, { FWRArrow(), FWDArrow(), "punto3" })
With Object oBrwCargaA
For i := 1 To Len( :aCols )
Switch i
Case 1
:aCols[ i ] : oDataFont := { || If( oBrwCargaA : oTreeItem : nLevel == 1, oFont4, If( oBrwCargaA : oTreeItem : nLevel == 2, oFont1, oFont2 ) ) }
:aCols[ i ] : cHeader := 'ALUMNOS'
Exit
EndSwitch
:aCols[ i ] : oHeaderFont := oFont1
Next i
:bClrHeader := { || { 0, CLR_WHITE } }
:nRowHeight := 27
:nHeaderHeight := 35
:nColDividerStyle := 1
:nRowDividerStyle := 1
:nColorPen := nRgb( 225, 225, 225 )
:nMarqueeStyle := 3
:nRecSelColor := CLR_WHITE
:lFlatStyle := .t.
:bClrSel := { || { CLR_BLACK, RGB( 255, 255, 255 ) } }
:bClrSelFocus := { || { CLR_WHITE, RGB( 43, 87, 154 ) } }
:lFlatStyle := .t.
:l2007 := .f.
:lKinetic := .f.
:lAllowRowSizing := .f.
:lHScroll := .f.
:nStretchCol := STRETCHCOL_LAST
:lColDividerComplete := .t.
:CreateFromCode()
EndWith
Activate Window oWndAlumnos Maximized On Init oBrwCargaA : SetFocus() Valid( oFont1 : End(), oFont2 : End(), oFont3 : End(), oFont4 : End(), .t. )
Return 0
//----------------------------------------------------------------------------//
Function DefineEntorno()
Set Epoch To 1950
Set Date To British
Set Delete On
Set Autopen Off
Set Softseek On
Set Century On
Set Confirm On
Set Decimals To 2
Set Fixed Off
Set Exact on
Set( _SET_INSERT, !Set( _SET_INSERT ) )
SetGetColorFocus( nRgb( 235, 245, 255 ) )
Request HB_LANG_ES
Hb_LangSelect("ES")
SetHandleCount( 200 )
Request DBFCDX
RddSetDefault( "DBFCDX" )
Request HB_CODEPAGE_ESWIN
Set( _SET_CODEPAGE, "ESWIN" )
XbrNumFormat( "E", .t. )
SetBalloon( .f. )
SetCenterOnParent( .t. )
aDatos()
Return 0
//----------------------------------------------------------------------------//
Static Function BuscaLosAlumnos()
Local i
Local q
Local nFor
Local aDatos
aCursos := ASort( aCursos,,, { | x, y | x[ 3 ] < y[ 3 ] } )
aSecciones := ASort( aSecciones,,, { | x, y | x[ 3 ] < y[ 3 ] } )
Tree oTree
For i := 1 To Len( aSecciones )
_TreeItem( aSecciones[ i ][ 2 ] ) : Cargo := { aSecciones[ i ][ 1 ] }
Tree
For q := 1 To Len( aCursos )
aDatos := {}
AEval( aAlumnos, { | x | If( x[ 3 ] == aCursos[ q ][ 1 ] .and. x[ 4 ] == aSecciones[ i ][ 1 ], Aadd( aDatos, { x[ 1 ], x[ 2 ], x[ 3 ], x[ 4 ] } ), ) } )
If( !Empty( aDatos ) )
_TreeItem( aCursos[ q ][ 2 ] ) : Cargo := { aSecciones[ i ][ 1 ], aCursos[ q ][ 1 ] }
Tree
For nFor := 1 To Len( aDatos )
_TreeItem( aDatos[ nFor ][ 2 ] ) : Cargo := { aSecciones[ i ][ 1 ], aCursos[ q ][ 1 ], aDatos[ nFor ][ 1 ] }
Next nFor
EndTree
End
Next q
EndTree
Next i
Endtree
oTree : Expand()
Return 0
//----------------------------------------------------------------------------//
Function aDatos()
aCursos := { { 1, "SALA VERDE - PRE JARDIN", 1 },;
{ 2, "SALA AMARILLA - 2 AÑOS", 2 },;
{ 3, "SALA AZUL - 3 AÑOS", 3 },;
{ 4, "SALA ROJA - 4 AÑOS", 4 },;
{ 5, "SALA NARANJA - 5 AÑOS", 5 },;
{ 6, "2 AÑOS 2015", 6 },;
{ 7, "3 AÑOS 2015", 7 },;
{ 8, "4 AÑOS 2015", 8 },;
{ 9, "5 AÑOS 2015", 9 },;
{ 10, "PRE JARDIN 2015", 10 },;
{ 11, "DEUDORES", 11 } }
aSecciones := { { 1, 'MAÑANA', 1 } }
aAlumnos := { { 1, "ABADI EMA OLIVIA", 2, 1 },;
{ 2, "ABADI HLADILO MARGARITA", 2, 1 },;
{ 3, "ALBORES JUANA", 2, 1 },;
{ 4, "ALIJO LUPKIN, PEDRO", 3, 1 },;
{ 5, "ALVAREZ CASADO, HELENA", 5, 1 },;
{ 6, "ASTORI, CAMILA", 3, 1 },;
{ 7, "AUGUSTOWSKI MORENA", 2, 1 },;
{ 8, "AUGUSTOWSKI, LUCAS", 5, 1 },;
{ 9, "AYALA TORALES, BENJAMIN", 3, 1 },;
{ 10, "BARCELO, JOSE", 4, 1 },;
{ 11, "BARDAUIL ASTOR", 5, 1 },;
{ 12, "BIANCHI SELZER ULISES", 2, 1 },;
{ 13, "BIANCHI SELZER, LISA", 4, 1 },;
{ 14, "BLANCO LIMERES CHARO", 3, 1 },;
{ 15, "BONDA CAMILO", 8, 1 },;
{ 16, "BONDA MARGARITA", 8, 1 },;
{ 17, "BORZESE JULIA", 6, 1 },;
{ 18, "BORZESE, LOLA", 3, 1 },;
{ 19, "BUNGE MANUEL", 6, 1 },;
{ 20, "BURITICA BRUNO", 3, 1 },;
{ 21, "CABRERA PEPER FRANCISCO", 2, 1 },;
{ 22, "CALURA CELESTE", 5, 1 },;
{ 23, "CALVO TORTI CAMILA", 6, 1 },;
{ 24, "CAO SALVADOR", 1, 1 },;
{ 25, "CAPRIGLIONE CATALINA", 2, 1 },;
{ 26, "CARNOTA, AMANDA", 4, 1 },;
{ 27, "CARRIERI, FACUNDO", 5, 1 },;
{ 28, "CUADROS SANTINO", 4, 1 },;
{ 29, "CUNDARI CARLI LOLA", 3, 1 },;
{ 30, "DAICH OLIVIA", 6, 1 },;
{ 31, "DEL AMO FARBER, LUCIA", 5, 1 },;
{ 32, "DESIMONE PACO", 1, 1 },;
{ 33, "DUBOURG, JOAQUIN", 11, 1 },;
{ 34, "ESTEVEZ, MILO", 4, 1 },;
{ 35, "ETCHEVERRY FELIPE", 5, 1 },;
{ 36, "FACCHINI FELIPE", 2, 1 },;
{ 37, "FAIG BRUNA", 2, 1 },;
{ 38, "FAIG, RENZO", 5, 1 },;
{ 39, "FERRAZ VAZQUEZ BRUNO", 6, 1 },;
{ 40, "FERRAZ VAZQUEZ VALENTIN", 3, 1 },;
{ 41, "FILEVICH IRENE", 1, 1 },;
{ 42, "GASCON, VIOLETA", 4, 1 },;
{ 43, "GELLON MAXON, MILA", 4, 1 },;
{ 44, "GOMEZ FESTA, JAZMIN SOL", 5, 1 },;
{ 45, "GOMEZ FESTA, JUAN MARTIN", 3, 1 },;
{ 46, "GONZALEZ FERREYRA, AGUSTINA", 5, 1 },;
{ 47, "GRIBNICOW MARC", 6, 1 },;
{ 48, "GRIBNICOW, LISA", 5, 1 },;
{ 49, "HERZOG VERA", 2, 1 },;
{ 50, "HITZIG, TANIA", 3, 1 },;
{ 51, "HUBERMAN, BENJAMIN", 4, 1 },;
{ 52, "HUERTA, CATALINA", 4, 1 },;
{ 53, "IANNI ZAHIR NICOLAS", 4, 1 },;
{ 54, "ISHII, HANNA", 5, 1 },;
{ 55, "ISKIN JOAQUIN", 1, 1 },;
{ 56, "JUVE, LAUTARO", 4, 1 },;
{ 57, "LAGATTA, FEDERICA", 4, 1 },;
{ 58, "LAURITO, ERNESTINA", 5, 1 },;
{ 59, "LEMESOFF SANTIAGO", 2, 1 },;
{ 60, "LEMESOFF, SOL", 4, 1 },;
{ 61, "LISOTTO EMILIA", 3, 1 },;
{ 62, "LOPEZ MORETTI MAXIMO", 1, 1 },;
{ 63, "MANDARANO MIGUEL", 6, 1 },;
{ 64, "MAROTTA ARBISER, VICENTE", 11, 1 },;
{ 65, "MAROTTA MOSEINCO, INES", 3, 1 },;
{ 66, "MARQUIS, LISA", 2, 1 },;
{ 67, "MATEOS SAMPIERI ROCIO", 6, 1 },;
{ 68, "MATTIOLI, FRIDA", 4, 1 },;
{ 69, "MENDEZ, JULIETA MICAELA", 5, 1 },;
{ 70, "MENENDEZ EMILIA", 1, 1 },;
{ 71, "MURTA CATALINA", 6, 1 },;
{ 72, "NOBILI CLARA", 1, 1 },;
{ 73, "NOBLIA, LUCIO", 3, 1 },;
{ 74, "PAZ BUNGE LUCIO", 2, 1 },;
{ 75, "PAZ BUNGE SERENA", 4, 1 },;
{ 76, "PELISCH LUCIO", 3, 1 },;
{ 77, "PICHARDO PAQUETTE, MATEO", 5, 1 },;
{ 78, "PISOTTI, OLIVIA ISABEL", 3, 1 },;
{ 79, "PONTURA, AMELIA", 11, 1 },;
{ 80, "PORTAS MARTINIANO", 7, 1 },;
{ 81, "PROSDOCIMI JUAN", 2, 1 },;
{ 82, "PROSDOCIMI, MATEO", 5, 1 },;
{ 83, "RAVAZZOLA SIGAL, JULIA", 5, 1 },;
{ 84, "REBOREDO, LUCAS", 5, 1 },;
{ 85, "RESTAINO, LUCAS", 5, 1 },;
{ 86, "REY INTI MATEO", 5, 1 },;
{ 87, "ROBBIO, TOMAS", 4, 1 },;
{ 88, "SAFAR SANTIAGO", 2, 1 },;
{ 89, "SAFARIAN DANTE JOSE", 4, 1 },;
{ 90, "SAFARIAN INES ESTHER", 4, 1 },;
{ 91, "SANTAMARINA LUCIO", 2, 1 },;
{ 92, "SASSON TULIO", 2, 1 },;
{ 93, "SCALA CARMELA", 4, 1 },;
{ 94, "SCALA FRANCO", 7, 1 },;
{ 95, "SCHUFER, IARA", 4, 1 },;
{ 96, "SIRI, MAXIMO", 11, 1 },;
{ 97, "SUAREZ RODRIGUEZ CATALINA", 2, 1 },;
{ 98, "TAGLIAFICO, BARBIERI SIMON", 3, 1 },;
{ 99, "TAMARIT ISABELLA", 3, 1 },;
{ 100, "TCHIRA RAFAEL", 6, 1 },;
{ 101, "TORRELLA CASARES FIDEL", 3, 1 },;
{ 102, "TSARIKTSIAN CLARA", 6, 1 },;
{ 103, "TSARIKTSIAN, FRANCO AGOP", 3, 1 },;
{ 104, "URBANCIC PAOLINI CIRO", 1, 1 },;
{ 105, "VAZQUEZ PETERS, LARA", 5, 1 },;
{ 106, "VAZQUEZ, GUADALUPE LUCIA", 3, 1 },;
{ 107, "VILLA GARCIA LLOSA AGUSTINA", 4, 1 },;
{ 108, "WEINTRAUB JULIETA", 4, 1 },;
{ 109, "WICHTER CAMILO", 4, 1 },;
{ 110, "WIRTH, PEDRO", 4, 1 },;
{ 111, "WOLKOWICZ, TEO", 4, 1 },;
{ 112, "YOHAI OLIVER", 4, 1 },;
{ 113, "YOHAI SARA LUCIA", 3, 1 },;
{ 114, "ZAHIR THOMAS", 6, 1 },;
{ 115, "ZUBIRI MAYRA SOL", 4, 1 },;
{ 117, "DELLACASA ANDRES", 1, 2 } }
Return 0
Define Window oWndAlumnos MDICHILD Of oWnd No Caption Border None Color 0, CLR_WHITE
@ 0, 0 xBrowse oBrwCargaA Of oWndAlumnos Size 300, 470 Noborder
Define Window oWndAlumnos MDICHILD Of oWnd No Caption Border None Color 0, CLR_WHITE
DEFINE BUTTONBAR oWndAlumnos:oBar SIZE 100,32 2007
DEFINE BUTTON OF oWndAlumnos:oBar PROMPT "Find" ACTION FindInTree( oBrwCargaA )
SET MESSAGE OF oWndAlumnos TO "" 2007
@ oWndAlumnos:oBar:nHeight, 0 xBrowse oBrwCargaA Of oWndAlumnos Size 300, -oWndAlumnos:oMsgBar:nHeight PIXEL Noborder
function FindInTree( oBrw )
local cFind := Space( 20 )
local oFound
if ! MsgGet( "Enter Search", "FIND", @cFind ) .or. Empty( cFind )
return nil
endif
cFind := Upper( AllTrim( cFind ) )
oFound := oBrw:oTree:Find( { |o| cFind $ o:cPrompt }, .t. )
if oFound == nil
? "Not Found"
else
oBrw:oTreeItem := oFound
oBrw:nRowSel := 50
oBrw:Refresh()
endif
return nil
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: paquitohm and 39 guests