StringGrid et Case of

cs_dud Messages postés 2 Date d'inscription dimanche 2 février 2003 Statut Membre Dernière intervention 14 avril 2004 - 14 avril 2004 à 10:46
DRJEROME Messages postés 436 Date d'inscription jeudi 9 janvier 2003 Statut Membre Dernière intervention 5 février 2015 - 15 mai 2004 à 09:30
Bonjour,
En fait, il faut récuperer des planning de personnes. La personne 1 sera disponible tel jour par ex le 11, alors on colorie la 11e case en vert dans le grid
La personne 2, sera elle disponible le 13, alors on colorie la case 13 en vert dans le StringGrid (ou planning c pareil)....

En gros, comment faire une boucle à partir du case et mettre un I qu'on incrémente à la place du 1 sachant que I ne peut pa aller...

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; 
  Rect: TRect; State: TGridDrawState); 
  var  format,i,titi:integer; 
  toto : char; 
begin 

      case (ARow) of 
      1:begin 
              for i:=0 to listbox1.Items.Count-1 do 
              begin 

                  try//intéressant quand tu lances le programme directement de l'exe (càd pas en mode création-compilation) 

                      if strtoint(listbox1.Items.Strings[i])=ACol then 
                      begin 
                          StringGrid1.canvas.font.color:=clBlue; 
                          StringGrid1.canvas.font.Style:=[fsBold]; 
                          StringGrid1.canvas.Brush.Color:=clGreen; 
                          StringGrid1.Canvas.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.bottom); 
                          InflateRect(Rect,0,-3);// je recentre le rect, ça fait plus joli 
                          DrawText(StringGrid1.Canvas.Handle,PChar(StringGrid1.Cells[ACol,ARow]),-1,Rect,DT_center or DT_VCENTER or DT_wordbreak); 
                      end; 
                  except 
                        on E : Exception do 
                        begin 
                              //ici je mets rien, mais au cas où la valeur du listbox n'est pas convertible en integer il y a exception 
                        end; 
                  end; 

              end; 
      end;//end de 1: 
      2:begin 

      end;//end de 2: 
      end;//end de case (ARow) of 
end; 

by dud

1 réponse

DRJEROME Messages postés 436 Date d'inscription jeudi 9 janvier 2003 Statut Membre Dernière intervention 5 février 2015
15 mai 2004 à 09:30
Dans :
StringGrid1.canvas.font.color:=clBlue; 
StringGrid1.canvas.font.Style:=[fsBold]; 
StringGrid1.canvas.Brush.Color:=clGreen; 
StringGrid1.Canvas.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.bottom); 
InflateRect(Rect,0,-3);// je recentre le rect, ça fait plus joli 
DrawText(StringGrid1.Canvas.Handle,PChar(StringGrid1.Cells[ACol,ARow]),-1,Rect,DT_center or DT_VCENTER or DT_wordbreak);

je reconnais des bouts de code que j'avais écrit, ça fait toujours plaisir de voir qu'on les réutilise :)

JROD DorotheeJ
0
Rejoignez-nous