델파이에서 stringgrid에 바탕색상을 넣고 싶어요
stringgrid에 하나의 필드값이 Y인경우 어떤 행은 빨간색,
어떤 행은 그 필드값이 N인경우 그냥 보통 흰색 이렇게 넣고 싶은데
어떻게하면 될까요??
안녕하세요?
TStringGrid에 조건에 따라 특정행에 바탕색상을 빨간색으로 넣고 싶다고 문의하셨는데
예제로 통해서 설명해드리겠습니다
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var rTextRect : TRect; sTempStr : string; I, J : integer; begin if TStringGrid(Sender).Cells[ARow, 6] = 'Y' then //6번째 필드값이 Y일경우 빨간색바탕화면 begin TStringGrid(Sender).Brush.Color := clRed; TStringGrid(Sender).Canvas.Font.Color := clBlack; sTempStr := TStringGrid(Sender).Cells[ARow, ACol]; rTextRect := TStringGrid(Sender).CellRect(ACol, ARow); TStringGrid(Sender).Canvas.FillRect(rTextRect); TStringGrid(Sender).Canvas.TextRect(rTextRect, rTextRect.Left + 6, rTextRect.Top + 4, sTempStr); end; end;