How are you? Hope you doing fine. My question: I have a FlowLayout with a lot of layouts inside it, and I need to hide a few based on a radio button selection, in design time it works fine I set the visible property to false and all the other layouts realign the right way, but when I do this at runtime it doesn't work, it keeps a white gap between the layout that has been hidden and the next one. When I do a resize manually (go to the form border and drag a little) it realigns and gets right, but if I select another radio the layout gets back and it override another layout so I need to resize manually again to realign. I tried to look at the source code of Resize but I got nothing relevant. What I tried: Repaint, Realign, InvalidateRect, RecalcAbsolute. Is there any way that I have to force the refresh of components?
procedure
TFrmApontamentoProducaoOrdemProducao.rbOrdensProducaoQuantidadeParcialClick(
Sender: TObject);
begin
if not lytQuantidadeParcial.Visible then
lytQuantidadeParcial.Visible := True;
// Tried to realign here
end;
procedure
TFrmApontamentoProducaoOrdemProducao.rbOrdensProducaoQuantidadeTotalClick(
Sender: TObject);
begin
if lytQuantidadeParcial.Visible then
lytQuantidadeParcial.Visible := False;
// Tried to realign here
end;
It's a simple code, but it's giving me a little problem. Thanks for the help, if you need more code or more details just let me know.
You must surround your code that makes changes to the layout of the TFlowLayout
with a pair of FlowLayout1.BeginUpdate;
and FlowLayout1.EndUpdate;
To assure that the update counter stays in sync, you should also use a try..finally..end
block.
For example
procedure TForm21.Button6Click(Sender: TObject);
begin
FlowLayout1.BeginUpdate;
try
Layout3.Visible := not Layout3.Visible;
finally
FlowLayout1.EndUpdate;
end;
end;