fil Posted August 10, 2020 Share Posted August 10, 2020 Hello, I try to create objects by dynamic. But when I create the child object I get an error. My code: type TParamString=record LabelNameSpace:TUniLabel; RadioGroup:TUniRadioGroup; RadioButton:TUniRadioButton; end; ... var ParamString:array of TParamString; ... SetLength(ParamString,0); SetLength(ParamString,10); for i:=1 to 10 do begin ParamString[i].RadioGroup:=TUniRadioGroup.Create(MainForm); ParamString[i].RadioGroup.Parent:= MainForm; ParamString[i].RadioGroup.Left:=10; ParamString[i].RadioGroup.Top:=i*50; ParamString[i].RadioGroup.Width:=200; ParamString[i].RadioGroup.Height:=45; ParamString[i].LabelNameSpace:=TUniLabel.Create(ParamString[i].RadioGroup); ParamString[i].LabelNameSpace.Parent:= ParamString[i].RadioGroup; ParamString[i].LabelNameSpace.Left:=10; ParamString[i].LabelNameSpace.Top:=5; ParamString[i].LabelNameSpace.Width:=75; ParamString[i].LabelNameSpace.Height:=25; ParamString[i].LabelNameSpace.Caption:=inttostr(i); end; How to correct create the child objects? Thanks Quote Link to comment Share on other sites More sharing options...
fil Posted August 10, 2020 Author Share Posted August 10, 2020 I understood. child cannot be created Quote Link to comment Share on other sites More sharing options...
fil Posted August 10, 2020 Author Share Posted August 10, 2020 End them Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 10, 2020 Share Posted August 10, 2020 Hello, Maybe you should take a look at this demo: \FMSoft\Framework\uniGUI\Demos\Desktop\Dynamic And please specify which edition and build of UniGUI are you using!? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 10, 2020 Share Posted August 10, 2020 1 hour ago, fil said: I understood. child cannot be created Hello, 1. Use instead inherited Objects 2. When you use dynamic array allocation for n values, you have to go to n+1. SetLength(ParamString, n+1); Then, you can work with : For i:=0 to n do Regards. Quote Link to comment Share on other sites More sharing options...
fil Posted August 10, 2020 Author Share Posted August 10, 2020 Looked at demos, unfortunately there are no examples with RadioButtons I need to group the RadioButtons but unfortunately: They are created but they all have one choice type TParamString=record LabelNameSpace:TUniLabel; RadioButton1:TUniRadioButton; RadioButton2:TUniRadioButton; RadioButton3:TUniRadioButton; Panel:TUniPanel; end; for i:=1 to 10 do begin ParamString[i].Panel:=TUniPanel.Create(MainForm); ParamString[i].Panel.Parent:= MainForm; ParamString[i].Panel.Left:=10; ParamString[i].Panel.Top:=i*50; ParamString[i].Panel.Width:=200; ParamString[i].Panel.Height:=45; ParamString[i].LabelNameSpace:=TUniLabel.Create(ParamString[i].Panel); ParamString[i].LabelNameSpace.Parent:= ParamString[i].Panel; ParamString[i].LabelNameSpace.Left:=5; ParamString[i].LabelNameSpace.Top:=5; ParamString[i].LabelNameSpace.Width:=75; ParamString[i].LabelNameSpace.Height:=25; ParamString[i].LabelNameSpace.Caption:='TEST'; ParamString[i].RadioButton1:=TUniRadioButton.Create(ParamString[i].Panel); ParamString[i].RadioButton1.Parent:= ParamString[i].Panel; ParamString[i].RadioButton1.Left:=50; ParamString[i].RadioButton1.Top:=5; ParamString[i].RadioButton1.Width:=75; ParamString[i].RadioButton1.Height:=25; ParamString[i].RadioButton1.Caption:='TEST'; ParamString[i].RadioButton2:=TUniRadioButton.Create(ParamString[i].Panel); ParamString[i].RadioButton2.Parent:= ParamString[i].Panel; ParamString[i].RadioButton2.Left:=100; ParamString[i].RadioButton2.Top:=5; ParamString[i].RadioButton2.Width:=75; ParamString[i].RadioButton2.Height:=25; ParamString[i].RadioButton2.Caption:='TEST'; end; Quote Link to comment Share on other sites More sharing options...
fil Posted August 10, 2020 Author Share Posted August 10, 2020 had to add a name to the Panel object ParamString.Panel.Name:='panel'+inttostr(i); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.