Recent

Author Topic: Using KGrid and TStringGrid components  (Read 3259 times)

morknot

  • Jr. Member
  • **
  • Posts: 57
  • still learning
Using KGrid and TStringGrid components
« on: July 11, 2015, 07:12:09 pm »
I am trying to use both the Lazarus TStringGrid and the tkweb KGrid in the same application. The grids are created at runtime. The problem I have is setting the Options parameters for the Lazarus TStringGrid.

newgrid is the newly created TStringGrid .......

With newgrid do
begin
Options:=[];
Options:=[goEditing,goThumbtracking];
end;

this results in: Error: Incompatible types: got "TGridOption" expected "TKGridOption"

If I remove goThumbtracking, which is not a KGrid Option (but goEditing is), this results in

Error: Incompatible type for arg no. 1: Got "Set Of TKGridOption", expected "TGridOptions"
grids.pas(2508,23) Hint: Found declaration: TCustomGrid.SetOptions(const TGridOptions);

So whichever way I try it, the expectation is for the other GridOptions.

There are no problems with setting the KGrid Options.

The documentation with KGrid discusses possible TKCustomGrid and TCustomGrid incompatibilities but does not specifically mention GridOptions:

"All properties available in standard grids have been implemented in KGrid. However there are several incompatibility issues
1. The class TKCustomGrid stands for TCustomGrid and TCustomDrawGrid. The class TKGrid stands for TStringGrid and TDrawGrid.....All types have the TKGrid prefix except the TKCustomGrid and TKGrid classes....."

Can anyone say whether this is likely to be the cause and if so possibly suggest a way round?

Thanks.



howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Using KGrid and TStringGrid components
« Reply #1 on: July 11, 2015, 07:35:27 pm »
You could try

Code: [Select]
Options:=[Grids.goEditing];

morknot

  • Jr. Member
  • **
  • Posts: 57
  • still learning
Re: Using KGrid and TStringGrid components
« Reply #2 on: July 11, 2015, 07:47:35 pm »
Many thanks howardpc. Works fine.

Perhaps one day I will understand programming.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Using KGrid and TStringGrid components
« Reply #3 on: July 12, 2015, 12:12:28 am »
In your uses clause you have a potential conflict because you have uses...,Grids,... together with whatever the KGrid unit is called (I'm not familiar with KGrid). Unfortunately these two different units use a single identifier (goEditing) which each defines differently. The Lazarus one is of type TGridOption, and the KGrid one is of type TKGridOption.

When the compiler parses the identifier goEditing it has no way to determine which type you mean unless you can disambiguate it by stating its origin. Writing it as Grids.goEditing identifies it unambiguously to the compiler as a variable of type TGridOption. Now the compiler is happy, knowing exactly what you want, and speeds on its way parsing everything else it finds...

morknot

  • Jr. Member
  • **
  • Posts: 57
  • still learning
Re: Using KGrid and TStringGrid components
« Reply #4 on: July 13, 2015, 11:21:27 am »
Howardpc - Thanks once again for your very clear explanation. It will be useful to remember this for possible future issues...........

 

TinyPortal © 2005-2018