Forum > LCL
TStringGrid vs. With
ivan17:
--- Quote from: asdf on October 28, 2010, 03:11:46 am ---It still worked with only TStringGrid exactly on TForm.
But it did not touch any TStringGrid in TPageControl or TTabSheet.
--- End quote ---
controls array lets you traverse direct children of a control. recurse through any container control like you did through form.
--- Quote from: asdf on October 28, 2010, 03:11:46 am ---I saw an idea; "visible".
How can I apply this property to such procedure?
--- End quote ---
like any other property. try it inside the with-block.
Zoran:
--- Quote from: ivan17 on October 28, 2010, 04:58:25 am ---controls array lets you traverse direct children of a control. recurse through any container control like you did through form.
--- End quote ---
Yes, so this is what you need:
--- Code: ---procedure TForm1.LightGrid;
procedure DoLightGrid(const C: TWinControl);
var
II: Integer;
begin
if C is TStringGrid then begin
showmessage(C.Name);
with TStringGrid(C) do begin
Flat:= true;
BorderStyle:= bsnone;
Options:= Options - [goVertLine];
end;
end;
for II := 0 to C.ControlCount - 1 do
if C.Controls[II] is TWinControl then
DoLightGrid(TWinControl(C.Controls[II]));
end;
begin
DoLightGrid(Self);
end;
--- End code ---
Now it works for all StringGrids on Form1, doesn't it? ;)
asdf:
Dear Zoran,
OMG! It's really great, thank you so much.
I'd like the user to look at it as if it is like a note book paper.
I'm now just starting reading www.delphibasics.co.uk.
Is this matter/technique described in such website?
Zoran:
--- Quote from: asdf on October 29, 2010, 04:33:10 am ---Dear Zoran,
OMG! It's really great, thank you so much.
I'd like the user to look at it as if it is like a note book paper.
--- End quote ---
You are welcome!
--- Quote from: asdf on October 29, 2010, 04:33:10 am ---I'm now just starting reading www.delphibasics.co.uk.
Is this matter/technique described in such website?
--- End quote ---
I don't know.
This basic lesson about recursion form Tao Yue's Pascal tutorial might be helpful to you.
Then try to solve "Towers of Hanoi" problem yourself, before you see the solution.
Navigation
[0] Message Index
[*] Previous page