This is simple example to Generate dynamics ax group control at runtime using code in x++ lanugage. You can try following code in form.
str groupMarkup = ' ';
str fieldsMarkup = ' ';
if (!_inGridControl && _inAxGroupControl == true)
{
_inAxGroupControl = false;
_markup.appendText(fieldsMarkup);
_markup.appendText('\r\n');
_markup.appendText(groupMarkup);
_markup.appendText('\r\n');
}