tags:

views:

47

answers:

1

Hi

I have this problem with TDrawGrid with fixed rows (although same applies to fixed cols).

If you have .FixedRows = 1, and decrement the value of .RowCount, when it gets to 1, the .FixedRows automatically gets set to 0, and your fixed rows turn white instead of the usual grey - except in column zero.

Can I stop this from happening? Is this a bug in TDrawGrid?

I realise I can put some code into OnDrawCell to check the rowcount and make paint some fake fixed rows for it if necessary, but I was hoping not to have to do this way.

Thanks all.

+1  A: 

As designed in the VCL code, it's a "feature" :-) :

procedure TCustomGrid.SetRowCount(Value: Longint);
begin
  if FRowCount <> Value then
  begin
    if Value < 1 then Value := 1;
    if Value <= FixedRows then FixedRows := Value - 1; // <= **@#$#@#$**
    ChangeSize(ColCount, Value);
  end;
end;
François
and it's a private, non-virtual method (in D6 at least) so it can't be easily overridden.
Gerry
...and still is in D2010!
François
Thanks gents this looks promising. I was just using a straight TDrawGrid...now I got a TCustomGrid going and overrode DrawCell only, and added the above proc. Its complaining about FRowCount and ChangeSize. Got any tips? I am a bit of a noob....
csharpdefector
Ah OK im an idiot as already stated. Thats the TCustomGrid source already you posted! :( Doh. What do reckon is best to do? Just paint 'fake' ones in DrawCell event?
csharpdefector
if you already have an onDrawCell event, you can use it for ensuring the FixedRows and RowCount do not fall down too much:` with Sender as TDrawGrid do if FixedRows < 1 then begin RowCount := 2; FixedRows := 1; end;`
François
Yes I could do that too, Thanks. This VCL 'Feature' is pretty disappointing :(
csharpdefector