Forum > LCL

[Solved] RadioGroup: Adding buttons dynamically.

(1/2) > >>

iru:
Gentlefolk,

Environment/s. Linux Mint 20.1, Laz 2.0.12 FPC 3.2.0. Win 10 Laz 2.0.10 FPC 3.2.0. Lenovo X240 I3.

At design time one adds 'strings' to RadioGroup1.Items.
In both environments the buttons and associated strings are displayed correctly.

At run time any items added dynamically by RadioGroup1.Items.Add('xxx') are NOT displayed!

I have read widely about RadioGroup in numerous forums, similar/same issues with a variety of resolutions but none make any difference.

I have tried all sorts of repaints, enable, etc, design time buttons are  displayed, none that are dynamically added.

If there is one design time item and I dynamically add two more a
vDebug := RadioGroup1.items.Count shows 2 items.

Any help, direction appreciated, Ian

GAN:
RadioGroup1.Items.Add('xxx') works fine.

Linux Mint 19.3 - Lazarus 2.0.8 and FPC 3.0.4


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    RadioGroup1: TRadioGroup;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  RadioGroup1.Items.Add('test');end; end.  

speter:
iru, maybe you should post a simple project showing the issue you are having.

Like GAN wrote, I have not found your issue (I am using Windows though).

I am attaching my project.

cheers
S.

iru:
Gentlefolk,

Thanks for the support.

I have downloaded the sample project from speter.

It works beautifully!!!!! On the same environment as my simple project that fails.......

I will do some more research. Ian

iru:
Gentlefolk,

I installed and compiled the example supplied by speter, it works correctly!

Back into my application with the problem, installed a new RadioGroup and a RadioGroup.items.Add('something') in Form.OnShow on a complex form with a tTabControl (Radiogroup1 not on the tab).

Same problem, nothing added to the RadioGroup.Items!!

Created a new clean form in the same application, added the RadioGroup and a RadioGroup.items.Add('something') in Form.OnShow.

It works!

Back to the form which fails, there in  OnShow  back some lines before the RadioGroup1.Items.Add is a
RadioGroup1 := tRadioGroup.Create(NIL).

Delete that and the the Item.Add works OK.

I would guess that the odd RadioGroup1 := tRadioGroup.Create(NIL) in a couple of my tests would have contributed to my problems.

I need to tidy up some things.....

But why did the RadioGroup1 := tRadioGroup.Create(NIL) cause a problem? The Items.Add were after that code.

I have some work to do. Thanks for the help, Ian.

Navigation

[0] Message Index

[#] Next page

Go to full version