Removing controls from a form at run time

In AX 4.0

I am creating a new form. It is a typical AX form with a tab control, the first tab containing a grid and the second tab containing various groups and edit controls. The difference is that the second tab page is created on the fly at run time based on what record is selected on the grid on the first tab page. I am using this.addControl() to add groups and then using formGroupControl.addControl() to add string and real controls inside the groups.

The problem is that if I switch back to the first tab page and come back it recreates all of the controls without removing the original controls. I can’t find a method that is the opposite of addControl() that I can use to remove all controls from the tab page when it is first activated so that it can be built fresh each time.

Does such a method exist and I am just too thick to find it? If not, is there some other way to make this happen?

Thanks,

Mike

Update:

I was able to figure this out. It can be done by looping through the controls on the form and getting the FormControlID for each one and then removing the with element.design().removeControl(FormControlID). Apparently removes need to be done at a higher level than the tab page.