realbasic-nug.it
[Top] [All Lists]

Re: Listbox colorazione riga subordinata a contenuto cella

To: REALbasic NUG Italian <realbasic-nug.it@lists.realsoftware.com>
Subject: Re: Listbox colorazione riga subordinata a contenuto cella
From: Massimo Valle <maxduepuntozero@yahoo.it>
Date: Tue, 16 Jun 2009 12:37:02 +0200
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug.it-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug.it-bounces@lists.realsoftware.com; domainkeys=pass (test mode) header.From=maxduepuntozero@yahoo.it
Delivered-to: listarchive@realsoftware.com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.it; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-Id:From:To:In-Reply-To:Content-Type:Content-Transfer-Encoding:Mime-Version:Subject:Date:References:X-Mailer; b=iLSbJSIP6Q8qNgJId1qwQaNlnRPBKUN/yWNnuq0RgwuGUNVl/+vi30hfpKumLH/JREwMQ9g5+V03lIGGxpJRNgvnOhB7fRTgYJhpBsgE10PWj6wRvLWp31nTER+OZfArwLqGeAnJK0myB1mBSQ1r690bB6PiHBDyKpg3/Oafg7Q= ;
Domainkey-status: good (test mode)
In-reply-to: <26d1d61d0906160005g5bb14543lcd237730624eb81b@mail.gmail.com>
References: <26d1d61d0906160005g5bb14543lcd237730624eb81b@mail.gmail.com>
Reply-to: REALbasic NUG Italian <realbasic-nug.it@lists.realsoftware.com>
Sender: realbasic-nug.it-bounces@lists.realsoftware.com

Il ciclo for...next è inutile perchè l'evento viene innescato automaticamente per OGNI cella in fase di ridisegno. Anche per quelle vuote.

Quindi, è necessario prima di tutto assicurarsi che si stia operando su una cella che contiene qualcosa:

  if row < me.listcount then

e quindi verificare che la cella sia quella giusta:

    If me.Cell(row, 1) = "Pippo" then

ma la cosa migliore a questo punto, per questioni di ottimizzazione sarebbe fare ancora un controllo se siamo sulla colonna giusta, onde evitare di effettuare il controllo di "Pippo" per ogni colonna. Quindi io sostituirei il tutto così:

  if row < me.listcount then
    if column = 1 then
      If me.Cell(row, 1) = "Pippo" then
        g.ForeColor=RGB(255,176,98) //Arancio
        g.FillRect(0,0,g.Width,g.Height)
      end if
    end if
  end if


Massimo Valle


On 16/giu/09, at 09:05, Massimo Lista wrote:

Per colorare una riga subordinata al valore contenuto in una cella avevo
scritto:Su Evento: CellBackgroundPaint

Dim i, TotRow, res As Integer
 Dim numriga As integer
 TotRow=me.ListCount
 for i=0 to TotRow -1
   If ListBox1.Cell(i,1) = "Pippo" then
       g.ForeColor=RGB(255,176,98) //Arancio
       g.FillRect(0,0,g.Width,g.Height)
   end if
 next
...ma non funzionava (vengono colorate tutte le righe pur intercettando l'if


Per farlo funzionare ho dovuto aggiungere if row =...
Dim i, TotRow, res As Integer
 Dim numriga As integer
 TotRow=me.ListCount
 for i=0 to TotRow -1
   If ListBox1.Cell(i,1) = "Pippo" then
     numriga = i
     if row = numriga  then
       g.ForeColor=RGB(255,176,98) //Arancio
       g.FillRect(0,0,g.Width,g.Height)
     end if
   end if
 next





<Prev in Thread] Current Thread [Next in Thread>