Q: Accessing Radiogroup Buttons throws exception This is a test application I made to reproduce the issue:

Please have a look at the following test code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(radioGroup1.Items[0]);
  ShowMessage(BoolToStr(radioGroup1.Buttons[0].Enabled));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowMessage(radioGroup1.Items[0]);
  ShowMessage(BoolToStr(radioGroup1.Buttons[0].Enabled)); //<- Fails!!!
end;

The first ShowMessage in FormCreate is shown, and displays the correct text (Item1).
The second code line in FormCreate throws an exception, that index is out of bounds.
If I run the same code in a button click event as shown in the code as well (after the form has loaded) everything works fine.
Question 1: 
It appears that the buttons have not been loaded at the time the second code line is executed in FormCreate.
Why is this the case, when the items themself appear to be loaded already?
Question 2: 
I noticed the issue when upgrading an existing (well working) project from Delphi 2006 to XE6.
This project now throws several exception in different Units because of this issue.
What has changed in this regards?
Thank for any help in advance!

A: The items are populated when the .dfm file is streamed in. That happens quite early on, certainly well before the OnCreate event fires. The buttons, which are windowed controls, are typically created when the window is created. And when the form's OnCreate event executes, the window has not been created.
You ask why the items exist, but the buttons do not. Well, the buttons are created from the items. But not immediately. The button creation is suppressed during form streaming, and that means that the items get populated first, and the buttons are created at some point later.
I'm not sure exactly what has changed from the older version of Delphi to the modern Delphi. If you go back to Delphi 6, you can see that the buttons are created in TCustomRadioGroup.ReadState, which executes during form streaming. But the latest versions of Delphi suppress the button creation in ReadState. My guess as to why this change was made is that it prevents you from setting button properties that get lost during window re-creation.
However, there's probably little point getting in to that in too much detail. The essential fact is that you cannot expect the buttons to exist during OnCreate. You should move any code that requires the buttons to exist to a different location. Some obvious candidates would be the form's OnShow event, or an overridden CreateWnd method.

A: Edit: It seems that RadioGroup.ControlCount remains 0 until you access the RadioGroup, so this solution won't work.
After reading this page, I did another search and found this page with a similar problem:
Problem with RadioGroup.ControlCount in Delphi 2010
It looks like the workaround to avoid throwing exceptions is to check if RadioGroup.ControlCount is greater than the index of the button you want to access.
If RadioGroup.ControlCount is 0, you probably don't want to access the radio group.
It doesn't really fix the problem of when to initialize it, but it solves the problem of when not to update it.
Dylan
