ScrollBar and StringGrid lazarus / 31-LCL ---------------------------------------------------------------------- asdf · 2011-01-19 08:03 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. ---------------------------------------------------------------------- Blaazen · 2011-01-19 11:34 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. ---------------------------------------------------------------------- asdf · 2011-01-20 11:36 Quote from: asdf on January 19, 2011, 09:03:43 amStringGrid1.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 ? QuoteStringGrid1.Height:=StringGrid1.RowHeights[0]+StringGrid1.RowHeig hts[1]+the horizontal scroolbar's height; ---------------------------------------------------------------------- Blaazen · 2011-01-20 11:51 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. ---------------------------------------------------------------------- Phil · 2011-01-20 15:27 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 · 2011-01-29 06:07 Quote from: Phil on January 20, 2011, 04:27:15 pm 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 ?