PDA

View Full Version : تغییر رنگ یک خانه از string gride



farideh_en
یک شنبه 18 تیر 1385, 16:46 عصر
سلام
چطور میشه رنگ یک خانه از stringride رو عوض کرد نه همشو
ممنون میشم راهنمایی کنین

m-khorsandi
چهارشنبه 18 مرداد 1385, 23:25 عصر
ویژگی DefaultDrawing مربوط به StringGrid رو False کنید و کد زیر و در OnDrawCell اون بنویسید:


if (ACol = 3) and (ARow = 3) then
begin
TStringGrid(Sender).Canvas.Brush.Color := clBlack;
TStringGrid(Sender).Canvas.Font.Color := clYellow;
end
else
begin
TStringGrid(Sender).Canvas.Brush.Color := clWhite;
TStringGrid(Sender).Canvas.Font.Color := clBlack;
end;

TStringGrid(Sender).Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, TStringGrid(Sender).Cells[ACol, ARow]);



برای اینکه بتونی نتیجه رو بهتر ببینی، سعی کن تو سطر و ستون 3 و 3 مقدار Test رو وارد کنی.