stringgrid cell color

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
uardal
Üye
Mesajlar: 2
Kayıt: 09 Oca 2018 03:01

stringgrid cell color

Mesaj gönderen uardal »

Arkadaşlar merhaba

Bir süredir delphiyle program yazıyorum ve stringgridle bazı çalışmalar yaptım. Stringgrid hücrelerini tek tek farklı renklerle doldurmak istiyorum. Stringgrid1 için bu işlemi yapıyorum ve hiç sorun çıkmadı fakat ikindi stringgrid için aynı komutları yazmama rağmen çalıştıramadım. Konu hakkında yardıma ihtiyacım var. Kullanıla kodlar aşağıda verilmiştir. Bu kodlarla stringgrid1 in hücrelerini renklendirebiliyorum. Fakat stringgrid2 için aynı sonucu alamıyorum.

Kolay gelsin.

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var CellText: string;
begin
//
if (ARow > 0) and (ACol > 0) then
begin
CellText := StringGrid1.Cells[ACol, ARow];
if Pos('KIR', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(Rect);

end
else if Pos('SARI', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := clYellow;
StringGrid1.Canvas.FillRect(Rect);

end
else if Pos('YES', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := rgb(0,255,0);
StringGrid1.Canvas.FillRect(Rect);

end

else if Pos('AF', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := rgb(0,255,0);
StringGrid1.Canvas.FillRect(Rect);

end
else if Pos('KS', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := $000080FF; //turuncu
StringGrid1.Canvas.FillRect(Rect);
end
else if Pos('SY', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := rgb(205,173,0); //
StringGrid1.Canvas.FillRect(Rect);
end

else if Pos('KF', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := clRed; //
StringGrid1.Canvas.FillRect(Rect);
end

else if Pos('YF', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := rgb(0,255,0); //
StringGrid1.Canvas.FillRect(Rect);
end


else if Pos('SF', CellText) > 0 then
begin
StringGrid1.Canvas.Brush.Color := clYellow; //
StringGrid1.Canvas.FillRect(Rect);
end


else
StringGrid1.Canvas.Brush.Color := clwindow;
StringGrid1.Canvas.TextOut(Rect.Left + 4, Rect.Top + 4, CellText);
end
end;
onur2x
Üye
Mesajlar: 19
Kayıt: 29 Şub 2016 12:20

Re: stringgrid cell color

Mesaj gönderen onur2x »

Sanırım tek prosedurde 2 tane StringGrid i renklendirmek istiyorsun StringGrid1 yazan yerlere Sender yazıp StringGrid2 ye de drawcell ine bu prosedürü atmalısın
uardal
Üye
Mesajlar: 2
Kayıt: 09 Oca 2018 03:01

Re: stringgrid cell color

Mesaj gönderen uardal »

Evet dediginiz gibi yaptim sorun yok su anda, ilginize tesekkur ederim.
Cevapla