Problem with Listview

Problem with Listview

Postby Eoeo » Sun Aug 19, 2012 10:05 pm

I cannot show a listview records

I have this database

Image

and I wish show the bitmpas into a listview

Image


but I can show only one record


why ?


this is my code

Code: Select all  Expand view
DEFINE DIALOG oDlg  SIZE nWidth, nHeight;
            TITLE "Selezionare una promozione";
            STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )

USE PROMO  ALIAS PR
 DO WHILE ! PR->(EoF())
    AAdd( aPromozioni,( TRIM(PR->PRDESC)))
    AAdd( aPromoImages,( allTRIM(PR->PRIMAGE)))
     PR->(DbSkip())
  ENDDO
CLOSE PR


oImageList = TImageList():New( 32, 32 )

@  63,2 GROUP TO  145,150   OF  oDlg  LABEL "Elenco promozioni"    PIXEL TRASPARENT



ACTIVATE DIALOG oDlg ;
                     ON INIT CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)





   FUNCTION CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)
   Local oLvw,oBtnUp,oBtnDown


   @ 145, 10 LISTVIEW oLvw SIZE 280,130 PIXEL ;
      ACTION MsgInfo( nOption )



     for i=1 to len(aPromozioni)
        oLvw:InsertItem(i-1 , aPromozioni[i] )
        oImageList:ReadBitmap( aPromoImages[i], 40,1)
     Next i

   oLvw:SetImageList( oImageList )


@  300,5 RBBTN oBtnUp    BITMAP ".\bitmaps\Up.BMP"  SIZE 40,40  OF  oDlg  PIXEL ;
        BORDER  CENTER ROUND ROUNDSIZE 2;
       ACTION  oLvw:KeyDown(VK_UP, 0)
@  300,55 RBBTN oBtnDown  BITMAP ".\bitmaps\Down.BMP"  SIZE 40,40  OF  oDlg  PIXEL;
       BORDER  CENTER ROUND ROUNDSIZE 2;
       ACTION   oLvw:KeyDown(VK_DOWN, 0)






   RETU NIL




 function InsertItems(oListView,aPromozioni)
Local n
for n=1 to len(aPromozioni)
 oListView:InsertItem( n, apromozioni[n] )
next n
retu nil

 




I tried also with icons
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Problem with Listview

Postby lucasdebeltran » Sun Aug 19, 2012 10:23 pm

Silvio,

We could try to help you with a full working sample.

Partial samples can´t be tested...
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: Problem with Listview

Postby Eoeo » Mon Aug 20, 2012 12:30 am

THIS THE TEST

Code: Select all  Expand view



#INCLUDE "Fivewin.ch"
#INCLUDE "Ribbon.ch"
#include "constant.ch"
#INCLUDE "XBROWSE.ch"


Function Promo_ListVw()
   Local oDlg,oBtn1,oBtn2
   Local bClrGrad := { | lPressed | If( ! lPressed,;
                           { { 1, nRGB( 253, 254, 255 ), nRGB( 179, 217, 255 ) } },;
                           { { 1, nRGB( 179, 217, 255 ), nRGB( 253, 254, 255 ) } } ) }

Local  nBottom   := 23
Local  nRight    := 39
Local  nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
Local  nHeight := nBottom * DLG_CHARPIX_H



Local lGridAll := TRUE
Local lGridRow := FALSE

Local oBtnConferma,oBtnAnnulla


Local oGridPromo,oBtnDown,oListView, oImageList

Local aPromozioni := {}
Local aPromoImages:= {}


CreateTestDbf()

SetDlgGradient( { { 1, RGB( 199, 150, 237 ), RGB( 237, 242, 248 ) } } )

                     

DEFINE DIALOG oDlg  SIZE nWidth, nHeight;
            TITLE "Selezionare una promozione";
            STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )


@ 40,14 SAY "Riga"+CRLF+"corrente" OF  oDlg   PIXEL    SIZE 40,16
@ 40,49 SAY "Tutto il"+CRLF+"documento" OF  oDlg PIXEL SIZE 40,16

@  15,10 RBBTN oBtn1   BITMAP ".\bitmaps\ONE.BMP"  SIZE 25,25  OF  oDlg  PIXEL ;
ACTION (obtn1:lSelected:=.t.,obtn1:REFRESH(),lGridRow:=FALSE,lGridAll:=TRUE,;
        obtn2:lSelected:=.f.,obtn2:REFRESH(),lGridRow:=TRUE,lGridAll:=FALSE)



@  15,45 RBBTN oBtn2   BITMAP ".\bitmaps\TODO.BMP" SIZE 25,25 OF  oDlg   PIXEL ;
ACTION (obtn1:lSelected:=.F.,obtn1:REFRESH(),lGridRow:=TRUE,lGridAll:= FALSE,;
        obtn2:lSelected:=.t.,obtn2:REFRESH(),lGridRow:=FALSE,lGridAll:=TRUE)

USE PROMO  ALIAS PR
 DO WHILE ! PR->(EoF())
    AAdd( aPromozioni,( TRIM(PR->PRDESC)))
    AAdd( aPromoImages,( allTRIM(PR->PRIMAGE)))
     PR->(DbSkip())
  ENDDO
CLOSE PR





oImageList = TImageList():New( 48, 48 )





   @   5,2 GROUP TO  60,150   OF  oDlg  LABEL "Ambito della promozione"   PIXEL TRASPARENT
   @  63,2 GROUP TO  145,150   OF  oDlg  LABEL "Elenco promozioni"    PIXEL TRASPARENT
   @ 150, 50  BTNBMP oBtnConferma PROMPT "&Conferma" OF oDlg FILENAME ".\bitmaps\DLG_OK.bmp" NOBORDER SIZE 50, 20 PIXEL  DEFAULT  ACTION   ( oDlg:end( IDOK ) )
   @ 150, 102 BTNBMP oBtnAnnulla PROMPT "&Annulla" OF oDlg FILENAME ".\bitmaps\DLG_NO.bmp" NOBORDER SIZE 50, 20 PIXEL  CANCEL ACTION  ( oDlg:end( IDCANCEL ) )
          oBtnConferma:bClrGrad = bClrGrad
          oBtnAnnulla:bClrGrad = bClrGrad
                     oBtnConferma:nLayout :=2
                     oBtnAnnulla:nLayout :=2


                    ACTIVATE DIALOG oDlg ;
                     ON INIT CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)


 IF oDlg:nresult == IDOK



 ENDIF

 RETURN NIL

  FUNCTION CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)
   Local oLvw,oBtnUp,oBtnDown


   @ 145, 10 LISTVIEW oLvw SIZE 280,130 PIXEL ;
      ACTION MsgInfo( nOption )



     for i=1 to len(aPromozioni)
        oLvw:InsertItem(i-1 , aPromozioni[i] )
        oImageList:ReadBitmap( aPromoImages[i], 40,1)
     Next i

   oLvw:SetImageList( oImageList )


@  300,5 RBBTN oBtnUp    BITMAP ".\bitmaps\Up.BMP"  SIZE 40,40  OF  oDlg  PIXEL ;
        BORDER  CENTER ROUND ROUNDSIZE 2;
       ACTION  oLvw:KeyDown(VK_UP, 0)

@  300,55 RBBTN oBtnDown  BITMAP ".\bitmaps\Down.BMP"  SIZE 40,40  OF  oDlg  PIXEL;
       BORDER  CENTER ROUND ROUNDSIZE 2;
       ACTION   oLvw:KeyDown(VK_DOWN, 0)






   RETU NIL



static function CreateTestDbf()

   local aCols := { { "PRCODE", 'C', 4, 0 }, { "PRDESC", 'C', 40, 0 }, ;
                    { "PRIMAGE", 'C', 60, 0 } }


  if .t. // ! File( "PROMO.DBF" )
      DBCREATE( "PROMO", aCols )
      USE PROMO EXCLUSIVE
      APPEND BLANK
      FIELD->PRCODE :="0001"
      FIELD->PRDESC :="PROMOZIONE  DI NATALE "
      FIELD->PRIMAGE:=".\bitmaps\verde.ico "
APPEND BLANK
      FIELD->PRCODE :="0002"
      FIELD->PRDESC :="PROMOZIONE  DI PASQUA "
      FIELD->PRIMAGE:=".\bitmaps\ROSSO.ico "

     USE
   endif

return nil





 
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Problem with Listview

Postby Eoeo » Tue Aug 21, 2012 4:19 pm

Any solution ?
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 78 guests