RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TFlowPanel.FlowStyle Property

Specifies the starting point and direction for controls added to a flow panel.

Pascal
property FlowStyle: TFlowStyle;
C++
__property TFlowStyle FlowStyle;

Use FlowStyle to set the starting position for the first control added to a flow panel, as well as the subsequent position for additional controls.

Flow Style 
Description 
BottomTopLeftRight  
The first control is at the bottom left corner of the panel. Subsequent controls are added from bottom to top and then from left to right.  
BottomTopRightLeft  
The first control is at the bottom right corner of the panel. Subsequent controls are added from bottom to top and then from right to left.  
LeftRightBottomTop  
The first control is at the bottom left corner of the panel. Subsequent controls are added from left to right and then from bottom to top.  
LeftRightTopBottom  
The first control is at the top left corner of the panel. Subsequent controls are added from left to right and then from top to bottom. This is the default setting.  
RightLeftBottomTop  
The first control is at the bottom right corner of the panel. Subsequent controls are added from right to left and then from bottom to top.  
RightLeftTopBottom  
The first control is at the top right corner of the panel. Subsequent controls are added from right to left and then from top to bottom.  
TopBottomLeftRight  
The first control is at the top left corner of the panel. Subsequent controls are added from top to bottom and then from left to right.  
TopBottomRightLeft  
The first control is at the top right corner of the panel. Subsequent controls are added from top to bottom and then from right to left.  

 

C++ Examples: 

//
//This example demonstrates the use of Flow panel to automatically
//align a set of controls and the different methods that can be used for that.
//A Stack is used to control the order of destruction of buttons.
//
void __fastcall TForm2::btAButtonClick(TObject *Sender)
{
    TButton *thisButton;
    TButton *lastButton;
    String temp;

    /* Sender is a TButton, cast it */
    thisButton = dynamic_cast<TButton*>(Sender);

    if (m_Stack->Count() > 0)
    {
        /* If there are buttons in stack, peek it */
        lastButton = dynamic_cast<TButton*>(m_Stack->Peek());

        /* Change the captions of this button and the last one */
        temp = thisButton->Caption;
        thisButton->Caption = lastButton->Caption;
        lastButton->Caption = temp;
    }
}

void __fastcall TForm2::btAddButtonClick(TObject *Sender)
{
    /* Create a new button */
    TButton *button = new TButton(m_FlowPane);

    button->Parent = m_FlowPane;
    button->Caption = IntToStr(m_Stack->Count());
    button->OnClick = btAButtonClick;

    /* Push the button to the stack */
    m_Stack->Push(button);
}

void __fastcall TForm2::btReArrangeClick(TObject *Sender)
{
    /* Change the current flow style (rotate them) */
    TFlowStyle newFlowStyle = m_FlowPane->FlowStyle;

    if (newFlowStyle == fsBottomTopRightLeft)
        newFlowStyle = fsLeftRightTopBottom;
    else
        newFlowStyle = newFlowStyle + 1;

    m_FlowPane->FlowStyle = newFlowStyle;
}

void __fastcall TForm2::btRemoveButtonClick(TObject *Sender)
{
    TButton *button;

    if (m_Stack->Count() > 0)
    {
        /* if the stack is not empty, pop the last button */
        button = dynamic_cast<TButton*>(m_Stack->Pop());
        delete button;
    }
}

void __fastcall TForm2::FormCreate(TObject *Sender)
{
    /* Create a new TFlowPanel pane and align it to client */
    m_FlowPane = new TFlowPanel(this);
    m_FlowPane->Parent = this;
    m_FlowPane->Align = alClient;

    /* Set the initial flowing style */
    m_FlowPane->FlowStyle = fsLeftRightTopBottom;

    /* Create the button stack */
    m_Stack = new TObjectStack();
}

void __fastcall TForm2::FormDestroy(TObject *Sender)
{
    /* Destroy the stack also */
    delete m_Stack;
}

 

Delphi Examples: 

{
This example demonstrates the use of Flow panel to automatically
align a set of controls and the different methods that can be used for that.
A Stack is used to control the order of destruction of buttons.
}
procedure TForm2.btAButtonClick(Sender: TObject);
var
  ThisButton : TButton;
  LastButton : TButton;
  Temp       : String;
begin
  { Sender is a TButton, cast it }
  ThisButton := Sender as TButton;

  if FStack.Count > 0 then
  begin
    { If there are buttons in stack, peek it }
    LastButton := FStack.Peek() as TButton;

    { Change the captions of this button and the last one }
    Temp := ThisButton.Caption;
    ThisButton.Caption := LastButton.Caption;
    LastButton.Caption := Temp;
  end;
end;

procedure TForm2.btAddButtonClick(Sender: TObject);
var
  Button : TButton;
begin
  { Create a new button }
  Button := TButton.Create(FFlowPane);
  Button.Parent := FFlowPane;
  Button.Caption := IntToStr(FStack.Count);
  Button.OnClick := btAButtonClick;

  { Push the button to the stack }
  FStack.Push(Button);
end;

procedure TForm2.btReArrangeClick(Sender: TObject);
var
  NewFlowStyle : TFlowStyle;
begin
  { Chnage the flow order (rotate) }
  NewFlowStyle := FFlowPane.FlowStyle;

  if NewFlowStyle = fsBottomTopRightLeft then
     NewFlowStyle := fsLeftRightTopBottom
  else
    Inc(NewFlowStyle);

  FFlowPane.FlowStyle := NewFlowStyle;
end;

procedure TForm2.btRemoveButtonClick(Sender: TObject);
var
  Button : TButton;
begin
  if FStack.Count > 0 then
  begin
    { if the stack is not empty, pop the last button }
    Button := FStack.Pop() as TButton;
    Button.Free();
  end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  { Create a new TFlowPanel pane and align it to client }
  FFlowPane := TFlowPanel.Create(Self);
  FFlowPane.Parent := Self;
  FFlowPane.Align := alClient;

  { Set the initial flowing style }
  FFlowPane.FlowStyle := fsLeftRightTopBottom;

  { Create the button stack }
  FStack := TObjectStack.Create();
end;

procedure TForm2.FormDestroy(Sender: TObject);
begin
  { Destroy the stack also }
  FStack.Free();
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!