Forum > LCL
Hidden controls inside of a flow panel still occupy space
Joanna:
I don't know if this is intended or not but the hidden controls inside of a flowpanel still occupy space and cause the flow panel to be bloated with extra blank space.
My current workaround is to remove invisible controls from the flovwpanel and only have flowpanel as parent for visible controls.
Perhaps the code for the tflowpanel needs some reworking to take visibility into account when sizing ?
Handoko:
Tested on Lazarus 2.3.0 GTK2 on Ubuntu Mate 64-bit.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; FlowPanel1: TFlowPanel; procedure Button4Click(Sender: TObject); procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button4Click(Sender: TObject);begin Button2.Visible := False;end; procedure TForm1.FormCreate(Sender: TObject);begin FlowPanel1.Anchors := [akLeft] + [akRight] + [akTop] + [akBottom];end; end.
After clicking the "Click Me" button, the Button2 will be hidden. It's working good on my test, or did I misunderstand what you meant?
Joanna:
have you tried making the flow panel a distinct color like clred and then trying to get the flow panel elements to be on one row? and then hiding one ?
when i do this the flow panel is wider than necessary because it is accommodating
the hidden control.
what does it look like if you hide button2?
Handoko:
Sorry, I couldn't reproduce it or fully understood what you said. Please provide a demo that shows the problem or at least modify the code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, ExtCtrls, StdCtrls; type { TForm1 } TForm1 = class(TForm) btnClickMe: TButton; FlowPanel1: TFlowPanel; procedure btnClickMeClick(Sender: TObject); procedure FormCreate(Sender: TObject); private FTarget: TButton; end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.btnClickMeClick(Sender: TObject);begin FTarget.Visible := False;end; procedure TForm1.FormCreate(Sender: TObject);var Button: TButton; i: Integer;begin Constraints.MinHeight := 300; Constraints.MaxHeight := 300; FlowPanel1.Anchors := [akLeft] + [akRight] + [akTop] + [akBottom]; FlowPanel1.Color := clRed; for i := 0 to 20 do begin Button := TButton.Create(FlowPanel1); Button.Parent := FlowPanel1; Button.Caption := i.ToString; Button.Color := $FF00AA + i * $BFF; if i = 6 then begin Button.Color := $00FF00; FTarget := Button; end; end;end; end.
Note: TButton.Color is not supported on Windows.
Joanna:
Thanks for trying to help , what happens if you have just 4 buttons and try to have the flow panel fit the buttons without extra space on one line then hide one of the buttons?
Also your picture shows a lot of extra space under the buttons. Are you able to have flowpanel fit around buttons without the blank area underneath?
I use tcdbuttons so I can control color 8)
Navigation
[0] Message Index
[#] Next page