Recent

Author Topic: [SOLVED] How to get StringGrid cell border color value  (Read 4356 times)

jamestien

  • New Member
  • *
  • Posts: 35
[SOLVED] How to get StringGrid cell border color value
« on: October 09, 2021, 09:05:14 am »
Hello fellow coders,

Im doing custom draw on fixed Row or Column, I want the cell border line color match the original cell board color. Anyone has idea how to retrive default StringGrid cell border color?

« Last Edit: October 18, 2021, 07:42:46 am by jamestien »
Lazarus 2.0.12/2.2.0RC1 (Win10, Xubuntu, Pop!Os)

wp

  • Hero Member
  • *****
  • Posts: 9034
Re: How to get StringGrid cell border color value
« Reply #1 on: October 09, 2021, 10:41:40 am »
Beginning with Laz 2.2RC1 there is a public Grid.FixedGridLineColor property which is used to draw the fixed cell borders. Note that you should also set Grid.Flat to true to turn off the 3D effect and to see the changed color.

(Note also that FixedGridLineColor is public, not published, therefore, it is not visible in the Object Inspector and can be set only in code).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamestien

  • New Member
  • *
  • Posts: 35
Re: How to get StringGrid cell border color value
« Reply #2 on: October 10, 2021, 05:19:08 am »
Thank you WP, will try it later.
Lazarus 2.0.12/2.2.0RC1 (Win10, Xubuntu, Pop!Os)

jamestien

  • New Member
  • *
  • Posts: 35
Re: How to get StringGrid cell border color value
« Reply #3 on: October 10, 2021, 05:33:05 am »
Beginning with Laz 2.2RC1 there is a public Grid.FixedGridLineColor property which is used to draw the fixed cell borders. Note that you should also set Grid.Flat to true to turn off the 3D effect and to see the changed color.

(Note also that FixedGridLineColor is public, not published, therefore, it is not visible in the Object Inspector and can be set only in code).

Thank you again WP, I'v test the sample code, its working but I was looking for on how to get grid color value so I can set Fixed Grid color same as Grid color for consistant & aesthetic looking. Please check the screenshot, I want to retrieve the value for the default grid color marked with Yellow highlight.
Lazarus 2.0.12/2.2.0RC1 (Win10, Xubuntu, Pop!Os)

Handoko

  • Hero Member
  • *****
  • Posts: 4384
  • My goal: build my own game engine using Lazarus
Re: How to get StringGrid cell border color value
« Reply #4 on: October 10, 2021, 11:50:47 am »
Try:

Code: Pascal  [Select][+][-]
  1.   StringGrid1.FixedGridLineColor := StringGrid1.GridLineColor;

It works on Linux but I haven't tried on Windows.

wp

  • Hero Member
  • *****
  • Posts: 9034
Re: How to get StringGrid cell border color value
« Reply #5 on: October 10, 2021, 12:00:59 pm »
Yes, it works on Windows, too. See attached extended demo.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamestien

  • New Member
  • *
  • Posts: 35
Re: How to get StringGrid cell border color value
« Reply #6 on: October 10, 2021, 05:09:25 pm »
Try:

Code: Pascal  [Select][+][-]
  1.   StringGrid1.FixedGridLineColor := StringGrid1.GridLineColor;

It works on Linux but I haven't tried on Windows.

Didn't know it was that simple...hahaha, thank you Handoko. hope now I can display Fixed grid line color on Linux properly after theme changed.
« Last Edit: October 10, 2021, 05:25:06 pm by jamestien »
Lazarus 2.0.12/2.2.0RC1 (Win10, Xubuntu, Pop!Os)

jamestien

  • New Member
  • *
  • Posts: 35
Re: How to get StringGrid cell border color value
« Reply #7 on: October 10, 2021, 05:26:05 pm »
Yes, it works on Windows, too. See attached extended demo.

Confirmed working WP, just what I need it, never knew it was that simple and StringGrid already has that property. Thank you again.
Lazarus 2.0.12/2.2.0RC1 (Win10, Xubuntu, Pop!Os)

Handoko

  • Hero Member
  • *****
  • Posts: 4384
  • My goal: build my own game engine using Lazarus
Re: How to get StringGrid cell border color value
« Reply #8 on: October 10, 2021, 05:46:55 pm »
Maybe you haven't known, Lazarus IDE have identifier completion features. Very useful.
https://wiki.freepascal.org/Lazarus_IDE_Tools#Identifier_Completion

For your case, after you type StringGrid1. then activate the identifier completion, you will get a list of available things/commands for the stringgrid.

jamestien

  • New Member
  • *
  • Posts: 35
Re: How to get StringGrid cell border color value
« Reply #9 on: October 10, 2021, 06:54:55 pm »
Maybe you haven't known, Lazarus IDE have identifier completion features. Very useful.
https://wiki.freepascal.org/Lazarus_IDE_Tools#Identifier_Completion

For your case, after you type StringGrid1. then activate the identifier completion, you will get a list of available things/commands for the stringgrid.

Yes, thank you Handoko for the advice. my bad, I haven't had look on the complete list of the identifier completion. so glad you are guys are so helpful there, I remember the last time you advised me that I can use "Insert Code" tag here for posting source code hehe.
Lazarus 2.0.12/2.2.0RC1 (Win10, Xubuntu, Pop!Os)

 

TinyPortal © 2005-2018