Recent

Author Topic: ScrollBar and StringGrid  (Read 12844 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
ScrollBar and StringGrid
« on: January 19, 2011, 09:03:43 am »
If it's a must to set as follows:
StringGrid1.RowCount = 2
StringGrid1.AutoSizeColumns=True
StringGrid1.Height:=StringGrid1.RowHeights[0]+StringGrid1.RowHeights[1]

If a text in a cell is longer than cell's width, AutoSizeColumns gives the scrollbar and hide row[1].

How can I get the proper StringGrid1.Height(plus the scrollbar's height) that is AutoSizeColumns friendly.
 
Lazarus 1.2.4 / Win 32 / THAILAND

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: ScrollBar and StringGrid
« Reply #1 on: January 19, 2011, 12:34:36 pm »
If I understand well your StringGrid has header. Then it depends if header is fixed or not (property FixedRows=0 or 1). How many rows it will have? Only two (header+one editable row) or more?

There is also property ScrollBars which you can change from ssAutoHorizontal -> ssHorizontal which can be solution. ScrollBar will be visible all the time (enabled or disabled, depend on grid's width).

There is also option goScrollKeepVisible which may solve it automatically.
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/

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: ScrollBar and StringGrid
« Reply #2 on: January 20, 2011, 12:36:35 pm »
StringGrid1.RowCount = 2
StringGrid1.AutoSizeColumns=True
StringGrid1.Height:=StringGrid1.RowHeights[0]+StringGrid1.RowHeights[1]

Yes, I only need to have 1 fixed row(header) and 1 grid row.

How can I calculate the horizontal scroolbar's height like hereunder ?
Quote
StringGrid1.Height:=StringGrid1.RowHeights[0]+StringGrid1.RowHeights[1]+the horizontal scroolbar's height;
Lazarus 1.2.4 / Win 32 / THAILAND

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: ScrollBar and StringGrid
« Reply #3 on: January 20, 2011, 12:51:21 pm »
There is a component TScrollBar, if I put it on my Form its height is 16 pixels. I believe it is the same scrollbar like that one under TStringGrid. And probably it is the same on all platforms.

So, try 16.
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/

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: ScrollBar and StringGrid
« Reply #4 on: January 20, 2011, 04:27:15 pm »
You should not make any assumption about the width of scroll bars, title bars, etc.

Take a look at the source for TStringGrid. You might be able to get some ideas on how to do it (grids.pas). For example, I see ClientHeight, whcih is defined as Height-HorzScrollbar.Size. However, this may not be available without subclassing TStringGrid since this record is in protected section.

I also see GridLineWidth, which could be useful.

Thanks.

-Phil

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: ScrollBar and StringGrid
« Reply #5 on: January 29, 2011, 07:07:51 am »

You should not make any assumption about the width of scroll bars, title bars, etc.

I also see GridLineWidth, which could be useful.


Could you please show me a few lines of sample code using GridLineWidth technique ?
Lazarus 1.2.4 / Win 32 / THAILAND

 

TinyPortal © 2005-2018