해당 열의 모든 숫자가 선택한 스타일에 맞도록 스타일을 적용하여 (내용 스타일 가져 오기) 열에 스타일을 적용하고 싶습니다. 숫자뿐입니다. 즉, 텍스트 문구에서 숫자가 발견되면 색깔이 표시됩니다. 이것이 가능한가 ?스타일을 사용하여 그리드의 cxgrid 색상 번호
답변
확실히. 이 거친 코드이지만 올바른 방향으로 당신을 얻을한다고
procedure TForm1.Column1StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
var
i: Integer;
begin
if TryStrToInt(ARecord.Values[Column1.Index], i) then
AStyle := cxStyle1;
end;
내가 시도 : StrToInt ('123') then ... but [dcc32 오류] Unit3.pas (140) : E2012 표현 유형이 BOOLEAN – user763539
이어야합니다 if 나는 사용한다 . TryStrToInt ('123456', 0) then then ... [dcc32 오류] Unit3.pas (140) : E2250이 인수로 호출 할 수있는 'TryStrToInt'의 오버로드 된 버전이 없습니다. 어쩌면 저는 엉망이되다 .... – user763539
@ user763539, TryStrToInt의 두 번째 매개 변수는 상수가 아니라 변수 여야합니다. 당신은 상수 (0)를 전달하는 이유는 당신이 컴파일러 오류가 발생합니다. –
같은 것을 사용합니다. 캔버스에 그림이 약간 겹칠 수 있지만 필요에 따라 조정할 수 있다고 생각합니다. 또한 문자열에서 숫자를 파싱하도록 조정해야합니다.
procedure TForm7.cxGrid1TableView1CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
var Bounds : TRect;
begin
Bounds := AViewInfo.Bounds;
ACanvas.Font.Color := clRed;
ACanvas.TextOut(Bounds.Left, Bounds.Top, '123');
Bounds.Left := ACanvas.Canvas.TextWidth('123');
ACanvas.Font.Color := clGreen;
ACanvas.TextOut(Bounds.Left, Bounds.Top, 'abc');
ADone := True;
end;
그것은 내 텍스트를 모두 123로 왜곡했습니다 ... 셀의 클릭 만 기본 텍스트를 보여줍니다. – user763539
가능 중복 [델파이 - cxdbgrid 필드 컨텐츠에 따라 착색 (http://stackoverflow.com/questions/20183431/delphi-coloring-cxdbgrid-field-depending-on-its-content) –
이전에 물어 본 질문과 같은 질문이 아닙니까? http://stackoverflow.com/questions/20183431/delphi-coloring-cxdbgrid-field-depending-on-its-content?rq=1 –
@SamM은 비슷하지만 같지 않습니다 ... 이제는 텍스트는 채색되어 텍스트는 그대로 유지됩니다. – user763539