has a easy way to Disabled many QRLabel?

I have a report which has many QRDBText and QrLabel(almost 70), I want to Endabled/Disabled some at runtime. Has a easy way to do that?. such as some Loop Statement

Thanks
kelvinyuAsked:
Who is Participating?
 
rwilson032697Connect With a Mentor Commented:
Try this:

var
  I : integer;

for I := 0 to ReportForm.ComponentCount do
  if ReportForm.Components[i] is TQRLabel then
    (ReportForm.Components[i] as TQRLabel).enabled := False; // or whatever

Cheers,

Raymond.
0
 
florisbCommented:
Yes there is, have a meeting now, answer from somebody else, otherwise later....

Started with:

procedure TForm1.Button1Click(Sender: TObject);
var
l : tbutton;
x : integer;
s : string;
begin
l := tbutton.create(self);
for x := 1 to 3 do
  begin
  s := 'button'+inttostr(x);
  //get form1.buttonX and enable...
  end;

end;
0
 
florisbCommented:
rwilson added the component loop, you could group your components in groups with the tag property and use sets to enable / disable a group.

  TSomeInts = 1..250;
  TIntSet = set of TSomeInts;


Drop 10 buttons on form, give them different tags:

procedure TForm1.Button1Click(Sender: TObject);
var
l : tbutton;
x : integer;
s : string;
ToDisable : TIntSet;
begin
ToDisable := [0,1,2];

//not needed: l := tbutton.create(self);
for x := 1 to form1.componentcount -1 do
  begin
  if form1.components[x] is tbutton then
    begin
    l :=  form1.Components[x] as tbutton;
    if l.tag in ToDisable then
      l.enabled := false;
    end;
  end;
end;
0
 
kelvinyuAuthor Commented:
thank rwilson
you answer can solve my problem

But Florisb's procedure is more suitable my case, because my report is a year statistic report, I need to disabled a group of lable by current month. thanks
0
 
florisbCommented:
no problemo,
F.
0
All Courses

From novice to tech pro — start learning today.