0

I have several StringGrid components in the same frame. All grids have the same headings. I would like to have the horizontal scrollbar of the frame show up automatically if the window is more narrow than the width of the StringGrid. The vertical scrollbar is showing up correctly.

The Frame containing the StringGrid components is set to Align: alClient. The StringGrid components are set to Align: alTop. Both the Frame and the Form have AutoScroll: true.

Here is the component hierarchy:

Form1
|- Frame21
  |- StringGrid1
  |- StringGrid2

This is what the form currently looks like (missing the horizontal scrollbar):

enter image description here

I don't want individual horizontal scroll bars in each StringGrid like this:

enter image description here


This doesn't work:

 __fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    this->Frame21->HorzScrollBar->Visible = true;
    this->HorzScrollBar->Visible = true;
}

Here is a related post that doesn't answer my question:

Only horizontal scrolling in a panel

rebecca
  • 113
  • 7
  • 1
    I have never relied on a Form/Frame's built-in scrollbars for scrolling content, so I'm just guessing, but you probably need to set `AutoSize=False` and `AutoScroll=True` on the Frame, and `AutoSize=False` and `AutoScroll=False` on the Form. Otherwise, have you tried placing the `TStringGrid` controls inside a client-aligned `TScrollBox` instead? – Remy Lebeau Jul 17 '20 at 17:39
  • Using a TScrollBox is working with the following alignment properties set: (TFrame is a child of TScrollBox) TFrame - alClient, TStringGrids - None; or TFrame - None, TStringGrids - alTop; or (TStringGrids children of TScrollBox, no TFrame) TStringGrids - None. – rebecca Jul 17 '20 at 20:13

1 Answers1

0

Set the alignment of the TStringGrid components to None and AutoScroll of the frame to true (no scrollbox is necessary).

rebecca
  • 113
  • 7