Recent

Author Topic: How are the titles of the fixed columns of a string grid set?  (Read 22529 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
How are the titles of the fixed columns of a string grid set?
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How are the titles of the fixed columns of a string grid set?
« Reply #1 on: June 13, 2013, 11:20:57 am »
Code: [Select]
  StringGrid1.Cells[0,0] := '0,0';
  StringGrid1.Cells[1,0] := '1,0';
  StringGrid1.Cells[2,0] := '2,0';
  StringGrid1.Cells[3,0] := '3,0';
  StringGrid1.Cells[4,0] := '4,0';
  //StringGrid1.Cells[5,0] := '5,0';

  //StringGrid1.Cells[0,0] := '0,0';
  StringGrid1.Cells[0,1] := '0,1';
  StringGrid1.Cells[0,2] := '0,2';
  StringGrid1.Cells[0,3] := '0,3';
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How are the titles of the fixed columns of a string grid set?
« Reply #2 on: June 13, 2013, 12:17:36 pm »
Or alternatively (if your grid is designed with columns) you can use:
Code: [Select]
StringGrid1.Columns[0].Title.Caption := 'MyTitle';and of course you can do it in Object Inspector.
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 are the titles of the fixed columns of a string grid set?
« Reply #3 on: June 13, 2013, 12:41:18 pm »
Does this mean that the cells of the fixed columns can only be set at runtime?
The Column editor doesn't appear capable of setting the titles of fixed columns.
Code: [Select]
  StringGrid1.Cells[0,0] := '0,0';
  StringGrid1.Cells[1,0] := '1,0';
  StringGrid1.Cells[2,0] := '2,0';
  StringGrid1.Cells[3,0] := '3,0';
  StringGrid1.Cells[4,0] := '4,0';
  //StringGrid1.Cells[5,0] := '5,0';

  //StringGrid1.Cells[0,0] := '0,0';
  StringGrid1.Cells[0,1] := '0,1';
  StringGrid1.Cells[0,2] := '0,2';
  StringGrid1.Cells[0,3] := '0,3';
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How are the titles of the fixed columns of a string grid set?
« Reply #4 on: June 13, 2013, 12:50:20 pm »
As far as I can see there is no way to set any data at design time on a StringGrid so yes it is only at runtime.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How are the titles of the fixed columns of a string grid set?
« Reply #5 on: June 13, 2013, 01:26:04 pm »
It's possible, you can double click string grid on the form designer at design time.
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/

CM630

  • Hero Member
  • *****
  • Posts: 1447
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How are the titles of the fixed columns of a string grid set?
« Reply #6 on: June 03, 2014, 12:02:15 pm »
Maybe I should mention some specific attitude toward the first row when FixedRow= 1;

Code: [Select]
  StringGrid1.Cells[0,0] := '0,0';
..


Or alternatively (if your grid is designed with columns) you can use:
Code: [Select]
StringGrid1.Columns[0].Title.Caption := 'MyTitle';

I am trying it, but none of the solutions offered does not work if FixedCols= 1 and FixedRows=1.

For example in the following code first two lines work, but the third line does not.

Code: [Select]

StringGrid1.Cells[0,0] := '0,0';
StringGrid1.Cells[0,1] := '0,1';
StringGrid1.Cells[1,0] := '1,0';

Respectively, 
Code: [Select]
StringGrid1.Columns[0].Title.Caption := 'MyTitle';

Will not change the title caption of the leftmost column, but of the next one.


Here is another case, when  FixedCols= 2 and FixedRows=2.
Code: [Select]
StringGrid1.Cells[0,0] := '0;0';
 StringGrid1.Cells[0,1] := '0;1';
 StringGrid1.Cells[0,2] := '0;2';
 StringGrid1.Cells[1,0] := '1;0';
 StringGrid1.Cells[1,1] := '1;1';
 StringGrid1.Cells[1,2] := '1;2';
 StringGrid1.Cells[2,0] := '2;0'; //Line not working
 StringGrid1.Cells[2,1] := '2;1';
 StringGrid1.Cells[2,2] := '2;2';
 StringGrid1.Cells[3,0] := '3;0'; //Line not working


Te recapitulate:
1. StringGrid1.Cells[y,0]  does not work in Row 0, when FixedRows is>0;
2.  StringGrid1.Columns[y].Title.Caption := 'MyTitle'; will not work when y is < FixedCols.
« Last Edit: June 03, 2014, 12:09:59 pm by paskal »
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How are the titles of the fixed columns of a string grid set?
« Reply #7 on: June 03, 2014, 03:14:51 pm »
Quote
Te recapitulate:
1. StringGrid1.Cells[y,0]  does not work in Row 0, when FixedRows is>0;
2.  StringGrid1.Columns[y].Title.Caption := 'MyTitle'; will not work when y is < FixedCols.
ad 2) It is expected behavior. Grid has fixed columns + columns designed by Columns property.

ad 1) Cells[] should work always, regardless how the grid was designed. BTW, coordinates are Cells[x, y] i.e. horizontal, vertical.

This:
Code: [Select]
StringGrid1.Cells[0,0] := '0,0';
StringGrid1.Cells[0,1] := '0,1';
StringGrid1.Cells[1,0] := '1,0';
works perfectly here.
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/

CM630

  • Hero Member
  • *****
  • Posts: 1447
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How are the titles of the fixed columns of a string grid set?
« Reply #8 on: June 03, 2014, 03:52:33 pm »
Here is where its hiding:
The following code works:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  MyStringGrid: TStringGrid;
begin
   MyStringGrid:=TStringGrid.Create(Form1);
   MyStringGrid.Parent:=Form1;
   MyStringGrid.Left:=8;
   MyStringGrid.RowCount:=3;
   MyStringGrid.ColCount:=3;
//   MyStringGrid.Columns.Add;
//   MyStringGrid.Columns.Add;
   MyStringGrid.FixedCols:=1;
   MyStringGrid.FixedRows:=1;
   MyStringGrid.Cells[0,0] := '0,0';
   MyStringGrid.Cells[0,1] := '0,1';
   MyStringGrid.Cells[1,0] := '1,0';
end;
And this code does not work:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  MyStringGrid: TStringGrid;
begin
   MyStringGrid:=TStringGrid.Create(Form1);
   MyStringGrid.Parent:=Form1;
   MyStringGrid.Left:=8;
   MyStringGrid.RowCount:=3;
//   MyStringGrid.ColCount:=3;
   MyStringGrid.Columns.Add;
   MyStringGrid.Columns.Add;
   MyStringGrid.FixedCols:=1;
   MyStringGrid.FixedRows:=1;
   MyStringGrid.Cells[0,0] := '0,0';
   MyStringGrid.Cells[0,1] := '0,1';
   MyStringGrid.Cells[1,0] := '1,0';
end;
I have no idea if that's how it should work or it's a bug.
« Last Edit: June 04, 2014, 02:26:16 pm by paskal »
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How are the titles of the fixed columns of a string grid set?
« Reply #9 on: June 03, 2014, 04:00:27 pm »
I see now. Changing Title of columns designed by Columns property is restricted of some reason. You can try to report it (if nobody else did yet).
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/

CM630

  • Hero Member
  • *****
  • Posts: 1447
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How are the titles of the fixed columns of a string grid set?
« Reply #10 on: June 04, 2014, 07:42:13 am »
Please let me know on which version of the both in your signature have you tried it, so I can add this info in the bugzilla.
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How are the titles of the fixed columns of a string grid set?
« Reply #11 on: June 04, 2014, 09:47:00 am »
In SVN 1.3 on Linux-Qt and 1.2 in Wine. IMO this restriction is useless.
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/

CM630

  • Hero Member
  • *****
  • Posts: 1447
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How are the titles of the fixed columns of a string grid set?
« Reply #12 on: June 04, 2014, 02:28:36 pm »
Reported as bug 26269.
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1447
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How are the titles of the fixed columns of a string grid set?
« Reply #13 on: June 11, 2014, 07:19:48 am »
So, the bug is fixed- it is now documented, and it became a feature.
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018