Recent

Author Topic: (Solved)Hiding Controls  (Read 1376 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
(Solved)Hiding Controls
« on: April 12, 2020, 05:56:36 am »
Is there a way to select all the controls on a form loop thru and set the visible attribute to true and/orfalse>

I'm sure I saw that question asked somewhere and answered but can't find it.

Thanks,
« Last Edit: October 23, 2020, 01:19:55 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: Hiding Controls
« Reply #1 on: April 12, 2020, 07:01:07 am »
Something like that?
Code: Pascal  [Select][+][-]
  1.   for i:=0 to ComponentCount-1 do
  2.     if Components[i] is TControl then TControl(Components[i]).Enabled:=False;  

or if you are sure about all the components to be hiden:

Code: Pascal  [Select][+][-]
  1. for i:=0 to ComponentCount-1 do
  2.   TControl(Components[i]).Visible:=False;  
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Hiding Controls
« Reply #2 on: April 12, 2020, 08:07:41 am »
@Gan
I'll try it. I assume Components refers to the form that has focus.
Odd that ComponentCount-1 isn't written Component.Count-1.

Oh well I'll try and if it osn't work I'll add the period.

 Thank you
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: Hiding Controls
« Reply #3 on: April 12, 2020, 08:35:42 am »
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Hiding Controls
« Reply #4 on: April 12, 2020, 09:08:49 am »
Thanks
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

jamie

  • Hero Member
  • *****
  • Posts: 6133
Re: Hiding Controls
« Reply #5 on: April 12, 2020, 12:51:42 pm »
If you lay all the controls of interest on something like a panel where the panel will be the parent to all the controls you want to hide then hiding the parent should hide all of the child controls..

 But I guess you have different things in mind..

 I find the best solution is to use the BeginUpdate …. do your changes EndUpdate calls
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018