How to iterate ButtonGroupControl in Form Extensions

Hello Please I have a quick question in Dynamics 365 FO

I want to iterate FormButtonGroupControl in Form Extensions > Controls


Based on some reasearches , i have the Following code

Here i iterate all form extensions of CustTable, but i dont know how to loop FormButtonGroupControl

public static void main(Args _args)
CLRObject list;
var t = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetFormExtensionNames(“CustTable”);

list = t.getEnumerator();
var extensionFormname = list.get_current();
AxFormExtension extendedForm = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetFormExtension(extensionFormname);
var enumerator = extendedForm.Controls.GetEnumerator();
AxFormExtensionControl extCtrl = enumerator.Current;
str nameOfControl = extCtrl.FormControl.Name;
if(extCtrl.FormControl.Type == MetaModel.FormControlType::ButtonGroup)
//Here i want to iterate the formButtonGroupControl and Get "FormButtonControl1"


Thanks in advance

It looks like a continue of the discussion we have in the Dynamics community forum for last few days…

Cast the variable to the right type and then use the Controls property to get the collection of child controls. Then simply iterate the collection.

You can find an example in my blog post New metadata API.

Why don’t want form button control iteration ? Please explain clearly