Forum > LCL
TStringGrid vs. With
asdf:
Procedure TForm1.LightGrid;
begin
i:= Form1.ControlCount;
for ii := 0 to i - 1 do
if Form1.Controls[ii] is TStringGrid then
showmessage(Form1.Controls[ii].Name); This line worked well.
begin
with Form1.Controls[ii] do What should I do with this line?
begin
Flat:= true; Error message - Identifier 'Flat' not found.
borderstyle:= bsnone;
Options:= Options - [goVertLine]; Error message - Identifier 'Options' not found.
end; //with
end; //if
end; //procedure
typo:
--- Code: ---if Form1.Controls[ii] is TStringGrid then
with TStringGrid(Form1.Controls[ii]) do
--- End code ---
asdf:
LightGrid;
This worked with only TStringGrids exactly on Form1.
But in Form1, there are lots of TPageControl.
And each TpageControl, there are lots of TTabSheets.
"LightGrid;" didn't work with TStringGrids on every TTabSheet.
I would like "LightGrid;" to work with all TStringGrids in everywhere they are in.
What code should be written more?
ivan17:
--- Code: ---Procedure TForm1.LightGrid;
begin
for ii := 0 to Form1.ControlCount - 1 do // no need for a variable - limit isn't recalculated
if Form1.Controls[ii] is TStringGrid then begin // <<< begin here
showmessage(Form1.Controls[ii].Name); [b][color=red]This line worked well.[/color][/b]
// that's because any control has a name. cast Controls[ii] to stringgrid to access the rest
with Form1.Controls[ii] as TStringGrid do begin
Flat:= true;
BorderStyle:= bsnone;
Options:= Options - [goVertLine];
end; //with
end; //if
end; //procedure
--- End code ---
asdf:
It still worked with only TStringGrid exactly on TForm.
But it did not touch any TStringGrid in TPageControl or TTabSheet.
.ControlCount didn't count TStringGrid in TPageControl or TTabSheet.
I saw an idea; "visible".
How can I apply this property to such procedure?
Navigation
[0] Message Index
[#] Next page