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;
stringgrid cell color
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Re: stringgrid cell color
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
Re: stringgrid cell color
Evet dediginiz gibi yaptim sorun yok su anda, ilginize tesekkur ederim.