Recent

Author Topic: Question about Grids  (Read 4620 times)

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Question about Grids
« on: March 26, 2011, 02:00:45 pm »
Hello,

I would like to create new StringGrid-like component with some improvements.
Two of those improvements are:
- Hint for every column (instead of one hint for whole grid)
- Ability to Fade out column when its ReadOnly property is True
and others...

It seems I will need my own
  TMyColumn = class (TColumn)
and my own
  TMyColumns = class (TCollection) - where collection items are TMyColumn

I mentioned only those related to TColumn because

TStringGrid is derived from TCustomStringGrid which is derived from TCustomDrawGrid which is derived from TCustomGrid

But TColumns is created in constructor TCustomGrid.Create so I cannot use
  TMyGrid = class (TStringGrid)
with constructor
  constructor TMyGrid.Create
  begin
    inherited Create;
   ....

Shortly said: I will need my own TMyCustomGrid because I need create my own TMyColumns and I do NOT want TColumns.

Am I right ? Or is there any simplier way ?

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/

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: Question about Grids
« Reply #1 on: March 26, 2011, 03:26:31 pm »
I understand. I've got the same kind of problem with TCanvas.

There are three solutions :

- to create your own class by copy'n'paste the existing ones (I suppose it's not a good idea)
- to override paint event and add some improvements here, for example using another list of columns that you make up-to-date with the previous one. Using both list of columns, you can add in the new ones the information you need (it's a trick that may work)
- to free the created columns and replace with others (likely to be impossible because columns are used in the code you cannot change)
- ask for a change in TCustomGrid, that a virtual procedure be added that creates columns. Then you would just have to override it in you class (the most elegant way but you may need to wait before your change is accepted and embedded in a new version of Lazarus)
Conscience is the debugger of the mind

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Question about Grids
« Reply #2 on: March 26, 2011, 03:45:01 pm »
Thanks for reply, it is what I needed to know.

I don't want to use the first method because it is not very elegant and - may happen - there will be some patches/improvements in a future which will not come to my code.

The second is probably what I will use.

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/

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Question about Grids
« Reply #3 on: March 26, 2011, 03:48:38 pm »
Have you looked at KGrid?  It may have what you are looking for.

http://www.tkweb.eu/en/delphicomp/kgrid.html

Lazarus Trunk / fpc 2.6.2 / Win32

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Question about Grids
« Reply #4 on: March 26, 2011, 04:11:58 pm »
Yes, I know KGrid, thanks for reply.

I don't want it because it seems too heavyweight for my purposes.
And I also wanted to try write my own component (with full back compatibility to TStringGrid).
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