I have a stringgrid which performs a word-wrap (and does it quite well), however ampersands (&) do not appear in the cell. Then if I click on the cell, it appears. Any ideas on how the solve this problem?
Here is the code:
------------------------------------
There's no place like 127.0.0.1
------------------------------------
Here is the code:
Code:
procedure TfrmMain.sgInvoiceDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
S: String;
drawrect :trect;
begin
//create a word break if a line exceeds column width
S:= sgInvoice.Cells[ACol, ARow ];
If Length(S) > 0 Then
begin
drawrect := rect;
DrawText(sgInvoice.canvas.handle,
Pchar(S), Length(S), drawrect,
dt_calcrect or dt_wordbreak); // or dt_left );
If (drawrect.bottom - drawrect.top) >
(sgInvoice.RowHeights[ARow]) then
sgInvoice.RowHeights[ARow] := (drawrect.bottom - drawrect.top)
// changing the row height fires the event again
else
begin
drawrect.Right := rect.right;
drawrect.Left := rect.Left + 2;
drawrect.Top := rect.Top + 2;
sgInvoice.canvas.fillrect( drawrect );
DrawText(sgInvoice.canvas.handle,
Pchar(S), Length(S), drawrect,
dt_wordbreak); // or dt_left);
end;
end;
end;
------------------------------------
There's no place like 127.0.0.1
------------------------------------