Page 1 of 1

How to Refresh a TreeView

Posted: Tue Dec 03, 2013 1:04 pm
by ctoas
How to Refresh a TreeView??

see the source

Code: Select all

********************************************************************************
STATIC FUNCTION TESTE()
********************************************************************************

    STATIC oTREE

    DEFINE DIALOG oDlg RESOURCE "CAD"

        oTree := TTreeView():Redefine( 4024, oDlg )

        REDEFINE BUTTONBMP oBtn ID 4025 OF oDlg ACTION ATUALIZATREE(oTree)

   ACTIVATE DIALOG oDlg CENTERED ON INIT MONTATREE( oTree )

RETURN NIL


********************************************************************************
FUNCTION MONTATREE( oTree )
********************************************************************************

   oITEM[01]:= oTREE:ADD( "ITEM1" )
      oSUBITEM[01]:=oITEM[01]:ADD( "ITEM1A" )
      oSUBITEM[02]:=oITEM[01]:ADD( "ITEM1B" )
      oSUBITEM[03]:=oITEM[01]:ADD( "ITEM1C" )
      oSUBITEM[04]:=oITEM[01]:ADD( "ITEM1D" )

   oITEM[02]:= oTREE:ADD( "ITEM2" )
      oSUBITEM[05]:=oITEM[02]:ADD( "ITEM2A" )
      oSUBITEM[06]:=oITEM[02]:ADD( "ITEM2B" )
      oSUBITEM[07]:=oITEM[02]:ADD( "ITEM2C" )
      oSUBITEM[08]:=oITEM[02]:ADD( "ITEM2D" )

    oTREE:EXPAND()

RETURN NIL

********************************************************************************
FUNCTION ATUALIZATREE(oTree)
********************************************************************************

   oITEM[01]:SETCHECK(.T.)
   oSUBITEM[01]:SETCHECK(.T.)
   oSUBITEM[02]:SETCHECK(.T.)
   oSUBITEM[03]:SETCHECK(.T.)
   oSUBITEM[04]:SETCHECK(.T.)

   oITEM[02]:SETCHECK(.T.)
   oSUBITEM[05]:SETCHECK(.T.)
   oSUBITEM[06]:SETCHECK(.T.)
   oSUBITEM[07]:SETCHECK(.T.)
   oSUBITEM[08]:SETCHECK(.T.)

   oTree:REFRESH() // there is no such method <-------------------

RETURN NIL
 

Re: How to Refresh a TreeView

Posted: Tue Dec 03, 2013 7:44 pm
by sambomb
Era pra ter sim!
TTreeView herda de TControl
TControl herda de TWindow

E não existe um método virtual para o comando refresh() então a TTreeView herda o Refresh da TWindow.

[EDIT]Conversando com o autor depois, o erro pelo visto era que o objeto não estava instanciado corretamente.[/EDIT]