Jump to content
Jud

Setting control properties in a loop

Recommended Posts

Posted (edited)

Never mind, I remembered how to do it:

 

    with TabSheet6.controls[ i] as tRadioGroup
     do ItemIndex := LandData[ index].LandWhoTo; 

==============================================

original:

I can set properties like top and left in a loop, but not other properties of a control.  Two examples below.  Is there a way to set these properties in a loop?

 

for i := 0 to TabSheet6.ControlCount - 1 do
if TabSheet6.controls[ i] is TEdit then

begin

  inc( index);
  TabSheet6.controls[ i].text := LandData[ index].LandName; // protected 

end; .// for, if

 

for i := 0 to TabSheet6.ControlCount - 1 do
if TabSheet6.controls[ i] is TRadioGroup then
begin
  inc( index);

  TabSheet6.controls[ i].top := 14 + 32 * index;
  TabSheet6.controls[ i].ItemIndex := LandData[ index].LandWhoTo; // undeclared identifier
end; // for, if

 

 

Edited by Jud

Share this post


Link to post
Posted (edited)

By googling, I think I found out how to do it;

    tRadioGroup( TabSheet1.controls[ i]).ItemIndex := LandData[ index].LandWhoTo;

 

=========================

original:

Well, this still says that ItemIndex is protected:

 

    with TabSheet6.controls[ i] as tEdit do
      TabSheet6.controls[ i].text := LandData[ index].LandName; // protected

 

Can it be set in a loop?

 

Edited by Jud

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×