Page 1 of 1

cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 2:52 pm
by wilsongamboa
Antonio buenos dias
tengo el siguiente codigo

Code: Select all  Expand view
   @ 15, 05 LISTBOX oSelf:oLbx1 VAR oSelf:cLbx1 OF oSelf:oDlg1 ;
             SIZE 750, 500;
             ITEMS oSelf:aItemsLbx
 


oSelf:aItemsLbx tiene ciertos valores
ahora quiero al ejecutar una acción cambiar el contenido del array y que se muestre el nuevo contenido
he revisado documentación de QT y no hallo como
saludos

Wilson

Re: cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 5:32 pm
by cnavarro
La accion que quieres ejecutar esta relacionada con el propio Listbox (por ejemplo al hacer dobleclick sobre un item), o se produce desde otro control (por ejemplo al pulsar un boton )?

Re: cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 7:39 pm
by wilsongamboa
Cristobal gracias por responder
Es un boton que quiero leer otros datos y cambie el array del listbox algo asi como
oLbx:setarray( aArray )
oLbx:refresh()
como te dije revise la documentación pero no lo hallo
saludos

Wilson

Re: cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 9:55 pm
by cnavarro
Prueba esto

Grabalo como "List00.prg"

Code: Select all  Expand view

#include "FiveTouch.ch"
     
function Main()
     
     local oDlg
     local oBtnCancel, cLbxItem
     local oBtn1, oBtn2, oBtn3

   DEFINE DIALOG oDlg

   @ 10, 10 LISTBOX oLbx VAR cLbxItem OF oDlg ;
             SIZE 380, 200 ;
             Items { "ListBox" }

   @ 250, 10 BUTTON oBtn1 PROMPT "Carga 1" OF oDlg ;
      ACTION ( Lee( 0, oLbx ), Lee( 1, oLbx ) )

   @ 250, 100 BUTTON oBtn2 PROMPT "Carga 2" OF oDlg ;
      ACTION ( Lee( 0, oLbx ), Lee( 2, oLbx ) )

   @ 250, 190 BUTTON oBtn3 PROMPT "Limpia" OF oDlg ;
      ACTION Lee( 0, oLbx )

   @ 250, 280 BUTTON oBtnCancel PROMPT "Cancel" OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

return nil             

Function Lee( n, oList )
Local x
Local cCad
Local nL
Do Case
   Case n = 0     // Solo Borrar Contenido

        For x = oList:Count() to 1 step -1
           oList:takeItem( x - 1 )
        Next x
       
   Case n = 1
      cCad := Memoread( "list00.prg" )
      nL   := MlCount( cCad )
      For x = 1 to nL
         oList:AddItem( Memoline( cCad, , x ) )
      Next x

   Case n = 2
      cCad := Memoread( "tutor01.prg" )
      nL   := MlCount( cCad )
      For x = 1 to nL
         oList:AddItem( Memoline( cCad, , x ) )
      Next x

EndCase
Return nil

 

Re: cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 10:31 pm
by wilsongamboa
Gracias Cristobal pruebo y te aviso
saludos
Wilson

Re: cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 10:37 pm
by cnavarro
Wilson, la function SetArray podria ser algo asi

Code: Select all  Expand view


Function QSetArray( aNew, oList )
Local x
Local nL := Len( aNew )

      For x = oList:Count() to 1 step -1
         oList:takeItem( x - 1 )
      Next x
      For x = 1 to nL
         oList:AddItem( aNew[ x ] )
      Next x

Return nil



 

Re: cambiar array de items e listbox

PostPosted: Thu Mar 12, 2015 11:34 pm
by wilsongamboa
Funcionó perfecto
muchas gracias

Wilson