Board index » delphi » TStringGrid and RowCount

TStringGrid and RowCount

Hi,
I am using a TStringGrid with FixedRows equal 1. When I set RowCount to
the actual number (including the fixed row), the visual distinct of the
first row vanishes. When I increment RowCount, the appearance of the
first row is okay, but I get an extra (unnecessary) row at the end.
What is wrong - did I miss anything?

:-( Hans-Peter  
--
+--------------------------------------------------------------+
| Hans-Peter Haberlandner       mailto:h...@technodat.co.at    |
| Technodat CAD/CAM             Phone: +43 - (0)662-454944-670 |
| Jakob Haringer-Strasse 6      FAX:   +43 - (0)662-454944-9   |
| A-5020 Salzburg                                              |
+--------------------------------------------------------------+

 

Re:TStringGrid and RowCount


In article <34852AED.1...@technodat.co.at>, Hans-Peter Haberlandner
wrote:

Quote
> When I set RowCount to the actual number (including
> the fixed row), the visual distinct of the first
> row vanishes.

The Delphi grids enforce a rule that FixedRows must always be less than
RowCount. Thus, if you set RowCount to 1, the grid will set FixedRows to
0 (via the SetRowCount property write method). If you later set RowCount
to a value greater than 1, FixedRows will still be 0.

This problem arises because the Delphi grids use "normal" cells as fixed
rows and columns. There are better ways to design this, but what's done
is done. Work-arounds include: 1) ensuring RowCount is always at least 2;
2) ensuring FixedRows is 1 when you set RowCount; or 3) using a separate
control, such as THeader, for your grid title row.

--
Rick Rogers (TeamB) | Fenestra Technologies

Re:TStringGrid and RowCount


Hi Rick,
thanks for your explanation. I realized that I set RowCount < 2 at the
very beginning.

:-) Hans-Peter

--
+--------------------------------------------------------------+
| Hans-Peter Haberlandner       mailto:h...@technodat.co.at    |
| Technodat CAD/CAM             Phone: +43 - (0)662-454944-670 |
| Jakob Haringer-Strasse 6      FAX:   +43 - (0)662-454944-9   |
| A-5020 Salzburg                                              |
+--------------------------------------------------------------+

Re:TStringGrid and RowCount


In article <34858728.7...@technodat.co.at>, Hans-Peter Haberlandner
wrote:

Quote
> I realized that I set RowCount < 2 at the very beginning.

I'm glad you asked here on the newsgroup... our little discussion
demonstrates the benefit of the shared experience available here. It
took me a while to figure out the RowCount < 2 quirk, and it was easy
for me to pass along that little tidbit of experience.

--
Rick Rogers (TeamB) | Fenestra Technologies

Re:TStringGrid and RowCount


Quote
Rick Rogers [TeamB] wrote:
> Hans-Peter Haberlandner wrote:

> > I realized that I set RowCount < 2 at the very beginning.

> I'm glad you asked here on the newsgroup... our little discussion
> demonstrates the benefit of the shared experience available here. It
> took me a while to figure out the RowCount < 2 quirk, and it was easy
> for me to pass along that little tidbit of experience.

Thanks, especially, for maintaining the inappropriate cross-post to
comp.lang.pascal.borland, a non-Delphi related group.

Quote
> --
> Rick Rogers (TeamB) | Fenestra Technologies

Fix your sig separator, should be "dash-dash-space."

--
New anti-SPAM mangled e-mail address...
My domain is airmail.net, not airmail.zzz
Support the anti-SPAM amendment... http://www.cauce.org/

Re:TStringGrid and RowCount


In article <34852AED.1...@technodat.co.at>, Hans-Peter Haberlandner
<h...@technodat.co.at> writes

Quote
>Hi,
>I am using a TStringGrid with FixedRows equal 1. When I set RowCount to
>the actual number (including the fixed row), the visual distinct of the
>first row vanishes. When I increment RowCount, the appearance of the
>first row is okay, but I get an extra (unnecessary) row at the end.
>What is wrong - did I miss anything?

>:-( Hans-Peter  

I often use (in Delphi 1) a separate grid immediately above the data
grid with the same column wcount and widths and make this look like a
fixed row. It has the advantage that I can preset a different row height
at desiign time to allow more than one line of header text. Then the
main grid has zero fixed rows.
Pat
--
Pat White
email: p...@pwhite.demon.co.uk
Phone; +44 (0)1925 266113

Other Threads