procedure TfmEdit.GridDB1TELCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); var R: TRect; s1,S2: string; X,dx,cx,C,Y: integer; begin if checkHighLight.EditValue = false then exit; ADone := true; R := AViewInfo.Bounds; s1 := AViewInfo.Text; C := Length(edSearch.Text); cx := ACanvas.TextWidth(edSearch.Text); ACanvas.FillRect(R); X := R.Left; if AViewInfo.Selected then ACanvas.Font.Color := clWhite else ACanvas.Font.Color := clBlack; ACanvas.Canvas.TextOut(R.Left + 1, R.Top + 1, S1); ACanvas.Font.Color := clRed; repeat Y := Pos(edSearch.Text, S1); if Y > 1 then begin S2 := Copy(S1,1,Y-1); dx := ACanvas.TextWidth(s2); Delete(S1,1,Y-1); Inc(X,dx); end; if Y > 0 then begin ACanvas.Canvas.TextOut(X + 1, R.Top + 1, copy(S1, 1, C)); Delete(S1,1,C); Inc(X,cx); end; until Y = 0; end; |