简体   繁体   English

FireMonkey FlowLayout 不刷新基于可见属性的项目

[英]FireMonkey FlowLayout isn't refreshing items based on visible property

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.我的问题:我有一个 FlowLayout,里面有很多布局,我需要根据单选按钮选择隐藏一些,在设计时它工作正常我将可见属性设置为 false,所有其他布局重新对齐右边方式,但是当我在运行时这样做时它不起作用,它会在已隐藏的布局和下一个布局之间保持空白。 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.当我手动调整大小(转到表单边框并拖动一点)时,它会重新对齐并正确,但如果我 select 另一个收音机布局会恢复并覆盖另一个布局,所以我需要再次手动调整大小以重新对齐。 I tried to look at the source code of Resize but I got nothing relevant.我试图查看 Resize 的源代码,但没有任何相关信息。 What I tried: Repaint, Realign, InvalidateRect, RecalcAbsolute.我尝试过:重绘、重新对齐、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;您必须使用一对FlowLayout1.BeginUpdate;将更改TFlowLayout布局的代码TFlowLayout起来FlowLayout1.BeginUpdate; and FlowLayout1.EndUpdate;FlowLayout1.EndUpdate; To assure that the update counter stays in sync, you should also use a try..finally..end block.为了确保更新计数器保持同步,您还应该使用try..finally..end块。

For example例如

procedure TForm21.Button6Click(Sender: TObject);
begin
  FlowLayout1.BeginUpdate;
  try
    Layout3.Visible := not Layout3.Visible;
  finally
    FlowLayout1.EndUpdate;
  end;
end;

Using BeginUpdate cause access violation on a project when insert chars from tcp-ip comunication in real time on FlowLayout, the solution:在 FlowLayout 上实时插入来自 tcp-ip 通信的字符时,使用 BeginUpdate 会导致项目访问冲突,解决方案:

var PodeAtualizarGrade:TCriticalSection; var PodeAtualizarGrade:TCriticalSection; ... ...

FormCreate PodeAtualizarGrade:=TCriticalSection.Create; FormCreate PodeAtualizarGrade:=TCriticalSection.Create; ... ...

PodeAtualizarGrade.Enter; PodeAtualizarGrade.Enter;

(FlowLayout.AddObjects ) (FlowLayout.AddObjects)

PodeAtualizarGrade.Leave; PodeAtualizarGrade.离开;

Works fine on my project.在我的项目上运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM