Ok here we go. First of all you have to set you security level, so go on tools, form options, security and trust, and select "full trust", you have to select one certifcate to sign your code, if you don't have one office can create one for you. After that on programming select C#.
Click Ok to close this window. After that you have to set an event handler on your field1 to create your rows right click on the field, programming and select change event, it will open a programming interface.
here you have to put some code:
XPathNavigator Root= this.MainDataSource.CreateNavigator();
//delete all rows of repeating table
try
{
Root.SelectSingleNode("/my:myFields/my:RepeatingTable/my:MyTable",this.NamespaceManager).DeleteRange(Root.SelectSingleNode("/my:myFields/my:RepeatingTable/my:MyTable[last()]",this.NamespaceManager));
}
catch { }
int NumOfRow=0;
//take the num of rows to create
int.TryParse(e.Site.Value, out NumOfRow);
for (int i = 1; i <= NumOfRow; i++)
{
XPathNavigator Clonenode = Root.SelectSingleNode("/my:myFields/my:ReferenceGroup/my:RepeatingTable/my:MyTable", this.NamespaceManager).Clone();
//add your code to divide here
Root.SelectSingleNode("/my:myFields/my:RepeatingTable", this.NamespaceManager).AppendChild(Clonenode);
}
You have to use your own xpath. I attach my own test form if it can help.