Long strings displayed in a grid column problem

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yevgeny
Posts: 15
Joined: Sun 11 Sep 2005 16:51
Location: Israel
Contact:

Long strings displayed in a grid column problem

Post by yevgeny » Wed 23 Apr 2008 10:13

Hi,

I use Delphi 7 with ODAC 5.80.0.41 Net and Oracle 10.2.0.3.

I encountered a problem of very slow repainting of CR grid columns containing long strings (specific long strings, not any ones).
I believe, though not sure, that some combination of chr(10) characters inside the text causes the problem.
Another condition that might affect this slow repainting is physical adding columns into the Columns property of the CR grid and then reducing the width of the column containing this long varchar text, but sometimes I receive this bug when there are no columns at all, in other words, when the grid creates columns according to dataset fields.

In addition there is another small display problem in the CR grid:
"enter" characters (chr(10) and chr(13)) are displayed as some garbage inside a grid column. In my case I see some Hebrew letters – I think this is because my "Language for non-Unicode programs" in the Regional Settings is Hebrew. When I set it to Russian, I see '::' in place of 2 Hebrew letters.

Please tell me when you are going to fix these problems.

Thanks,
Yevgeny

P.S. I sent a test project where this problem can be reproduced along with the script for creating the table with problematic long texts to support()crlab.com.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 23 Apr 2008 13:42

CRControls components are no longer supported by Core Lab. These components are shipped with sources so you can edit them as you like.

yevgeny
Posts: 15
Joined: Sun 11 Sep 2005 16:51
Location: Israel
Contact:

Post by yevgeny » Sun 27 Apr 2008 09:05

I fixed the bug.
The problem was in drawing 3 dots ('...') in the end of a string column when the text is longer than the column can display according to its current width.

The problem is in TCRDBGrid.DrawColumnCel method.
The problematic code is:

Code: Select all

while (TextWidth > ColWidth) and (Length(Value) > 1) do begin
  SetLength(Value, Length(Value) - 1);
  TextWidth := Canvas.TextWidth(Value) + TextMargin + ThreeDotWidth;
end
Value := Value + ThreeDot;
I changed it to this one:

Code: Select all

prev_s := Value;
for j := 1 to Length(Value) do
  begin
    if (Value[j]  Chr(10)) and (Value[j]  Chr(13)) and (Value[j]  UnicodeEOL) then
      s := s + Value[j]
    else
      s := s + ' ';
    TextWidth := WideCanvasTextWidth(Canvas, s) + TextMargin + ThreeDotWidth;
    if TextWidth >= ColWidth then
      begin
        Value := prev_s + ThreeDot;
        Break;
      end;
      prev_s := s;
  end;
I am using WideCanvasTextWidth because my CR grid supports Unicode.
The line 'if (Value[j] Chr(10)) and (Value[j] Chr(13)) and (Value[j] UnicodeEOL)' fixes another display bug I mentioned in the original post (UnicodeEOL = #$0D#$0A).

Post Reply