Recent

Author Topic: How can the width of the fixed columns of a TStringGrid be set?  (Read 8655 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
How can the width of the fixed columns of a TStringGrid be set?

It seems they can't be set at design time in the property editor.
Lazarus 3.0/FPC 3.2.2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How can the width of the fixed columns of a TStringGrid be set?
« Reply #1 on: July 03, 2013, 12:45:03 am »
Yes. There's only "DefaultColWidth" property. I personally prefer string grid designed with Columns instead of fixed columns design. IMO it is more flexible and more configurable.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Re: How can the width of the fixed columns of a TStringGrid be set?
« Reply #2 on: July 03, 2013, 01:56:21 am »
Can't they be set at runtime? There seems to be no Column index for the fixed columns. Columns[0] seems to apply to the first normal column
Yes. There's only "DefaultColWidth" property. I personally prefer string grid designed with Columns instead of fixed columns design. IMO it is more flexible and more configurable.
Lazarus 3.0/FPC 3.2.2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How can the width of the fixed columns of a TStringGrid be set?
« Reply #3 on: July 03, 2013, 02:10:33 am »
You can use indexed property "ColWidths" for fixed columns at runtime:
Code: [Select]
StringGrid1.ColWidths[1]:=100;Of course, it is indexed from 0.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Re: How can the width of the fixed columns of a TStringGrid be set?
« Reply #4 on: July 03, 2013, 10:32:20 am »
I tried the ColWidths[0] property and it works.

What seems wrong to me is that stringgrid.Columns[0].Width doesn't work at runtime.

Isn't that be a bug in the implementation?

It is a bug to me, or is it the kind of historical baggage which breaks existing code when removed?

You can use indexed property "ColWidths" for fixed columns at runtime:
Code: [Select]
StringGrid1.ColWidths[1]:=100;Of course, it is indexed from 0.
Lazarus 3.0/FPC 3.2.2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How can the width of the fixed columns of a TStringGrid be set?
« Reply #5 on: July 03, 2013, 12:41:27 pm »
I think it is by design. You can have string grid defined via fixed columns, defined via Columns[] or you can mix it (a few fixed + a few Columns[]). Property ColWidth[] is flexible, no matter how are columns defined. Columns[].Width is only for Columns[] and never for fixed columns.

Example: 5 fixed columns + 5 Columns[]
Code: Columns[1].Width := 120;
will change width of the 6-th column.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018