--- El mar 5-oct-10, Graeme Geldenhuys <[email protected]> escribió:
> De: Graeme Geldenhuys <[email protected]>
> Asunto: [Lazarus] StringGrid header row is always blank at runtime?
> A: "Lazarus mailing list" <[email protected]>
> Fecha: martes, 5 de octubre de 2010, 3:36
> Hi,
>
> In the tiOPF project we have an Model-GUI-Mediator
> implementation.
> Something like Model-View-Presenter. Anyway, list
> objects can be
> represented in a GUI via ListView or StringGrid component.
>
> Today when I retested the LCL demos of tiOPF, I found that
> all
> StringGrid mediators don't have the header (fixed row)
> anymore. The
> line is there, but it's totally blank. All the
> correct data is
> displayed, so the line count is correct. I double checked
> and the
> column headers are created, captions are set, alignment is
> set, but at
> runtime it is just blank. See attached image.
>
> At design time, I can see FixedRow = 1, there is a gray
> shaded header
> row painter with the default 4 empty rows. But at runtime
> this is all
> different.
>
> Can anybody shed some light on what has recently been
> changed in
> TStringGrid to cause this behaviour. More importantly, what
> must I
> change to get it to work like it used to work in 0.9.28?
>
There have been many changes in grid, and still need to be checked if there are
regressions, this could be the case here because it seems when grid is cleared
it doesn't 'remember' the number of fixed rows there was previous to being
cleared.
Easy to fix in tiOPF and if we find this is a regression in grids code, tiOPF2
should not need posterior amendment. Take a look at the attached patch. BTW,
included also is a way to make the last column resizeable at run time using
grids features instead of doing calcs with grids internals.
Jesus Reyes A.
Index: tiListMediators.pas
===================================================================
--- tiListMediators.pas (revisi¢n: 1858)
+++ tiListMediators.pas (copia de trabajo)
@@ -422,36 +422,25 @@
i: integer;
lColumnTotalWidth: integer;
C : TGridColumn;
- lGridNonContentWidth: integer;
- lLastColumnWidth: integer;
begin
- lColumnTotalWidth := 0;
View.Columns.Clear;
// Grid is 2 pixel border left + right, 1 pixel col gridline separator
- lGridNonContentWidth := 2 + 2 + (FieldsInfo.Count - 1);
for i := 0 to FieldsInfo.Count - 1 do
begin
C:=View.Columns.Add;// as TGridColumn;
C.Width := FieldsInfo[i].FieldWidth;
C.Title.Caption := FieldsInfo[i].Caption;
C.Alignment := FieldsInfo[i].Alignment;
- //resize the last column to fill the grid.
- if i = FieldsInfo.Count - 1 then
- begin
- if View.Width > (lColumnTotalWidth + lGridNonContentWidth) then
- begin
- lLastColumnWidth := View.Width - (lColumnTotalWidth + lGridNonContentWidth);
- if lLastColumnWidth > 10 then
- C.Width := lLastColumnWidth;
- end;
- end
+ if i = FieldsInfo.Count -1 then
+ C.SizePriority := 1
else
- lColumnTotalWidth := lColumnTotalWidth + C.Width;
+ C.SizePriority := 0;
end;
if ShowDeleted then
View.RowCount := Model.Count
else
View.RowCount := Model.CountNotDeleted;
+ View.FixedRows := 1;
end;
procedure TtiStringGridMediatorView.SetupGUIandObject;
@@ -461,6 +450,7 @@
View.Options:=View.Options+[goRowSelect,goThumbTracking];
// Rowcount is set after columns are created, because clearing columns
// resets rowcount.
+ View.AutoFillColumns := true;
end;
procedure TtiStringGridMediatorView.ClearList;
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus