Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-10

TStringGrid.AutoSizeColumns leads to temporary ghost columns

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jürgen Hestermann

I wrote a program for Windows that uses TStringGrid.AutoSizeColumns after filling the columns with text.
Autosizing leads to smaller columns in my case.

On one machine (WinXP SP3) it works ok.
But on another machine (WinXP SP2) the most right column is still visible at its original place after AutoSizing so I see it twice. Toggling to another program and back with Alt+TAB lets it disappear.

Anybody seen this?
Is it a Windows bug or a bug of TStringGrid.AutoSizeColumns?

Reply by email

Jürgen Hestermann
to Jürgen Hestermann
But on another machine (WinXP SP2) the most right column is still visible at its original place after AutoSizing so I see it twice. Toggling to another program and back with Alt+TAB lets it disappear.

It seems that his only happens when the number of lines fits within the current window.
If there are more lines then this does not happen.

Reply by email

Jürgen Hestermann
to cobines
If you have a way to reproduce you should create a small project and make a report to the bugtracker.

I have narrowed it down as far as I could now.

My form contains a simple TStringGrid.
ColCount is 3 and RowCount is 1 on startup (in object inspector). On Click the procedure "Start" is launched:

------------------------------------------------------------
procedure TForm1.Start(Sender: TObject);
var i,j  : LongInt;
begin // TForm1.Start
Grid.Clear;
for j := 1 to 5 do
   begin
   with Grid do
      begin
      RowCount := RowCount+1;
      Cells[0,Grid.RowCount-1] := 'XXXX '+IntToStr(j);
      end;
   for i := 1 to 3 do
      begin
      if Grid.Cells[1,Grid.RowCount-1]='' then
         begin
         Grid.Cells[1,Grid.RowCount-1] := 'Test in 1';
         Grid.Cells[2,Grid.RowCount-1] := IntToStr(i);
         end
      else
         begin
         //StringGridAddRow(Grid,Grid.RowCount);
         with Grid do
            begin
            RowCount := RowCount+1;
            Cells[1,Grid.RowCount-1] := 'New in 1';
            Cells[2,Grid.RowCount-1] := IntToStr(i);
            end;
         end;
      Application.ProcessMessages;
      end;
   end;
Grid.AutoSizeColumns;
end; // TForm1.Start
procedure TForm1.GridPrepareCanvas(Sender : TObject; aCol,aRow :
Integer; aState : TGridDrawState);
var MyTextStyle : TTextStyle;
begin // TForm1.GridPrepareCanvas
if (aCol=2) or (aCol=0) then
   begin
   MyTextStyle           := Grid.Canvas.TextStyle;
   MyTextStyle.Alignment := taRightJustify;
   Grid.Canvas.TextStyle := MyTextStyle;
   end;
end; // TForm1.GridPrepareCanvas
------------------------------------------------------------

The ghost column only appears if all rows and columns fit within the window for "Grid".
If I leave out the "GridPrepareCanvas" the ghost column still appears but without content.
If I leave out the "Application.ProcessMessages" the ghost column does not else who can reproduce it with the code above?

Reply by email

Jesus Reyes
to Jürgen Hestermann

--- El dom 23-oct-11, J?rgen Hestermann escribi?:

Show quoted text 15 lines
De: J?rgen Hestermann Asunto: Re: [Lazarus] TStringGrid.AutoSizeColumns leads to temporary ghost columns A: "Lazarus mailing list" Fecha: domingo, 23 de octubre de 2011, 9:54 cobines schrieb: > If you have a way to reproduce you should create a small project and > make a report to the bugtracker. >??? I have narrowed it down as far as I could now. My form contains a simple TStringGrid. ColCount is 3 and RowCount is 1 on startup (in object inspector). On Click the procedure "Start" is launched:

[snip]

Anybody else who can reproduce it with the code above?

fixed in r33058
please test.

Jesus Reyes A.

Reply by email