This method sets the current value of the Answer object to the value at the specified repeat indexes.
void SetRepeatIndex ( int repeat1, int repeat2, int repeat3, int repeat4 )
Parameter | Description |
repeat1 | First repeat index for the desired value. |
repeat2 | Second repeat index for the desired value. |
repeat3 | Third repeat index for the desired value. |
repeat4 | Fourth repeat index for the desired value. |
Any unused repeat indexes must be set to -1. For instance, if you want to reference the fourth iteration of the first level of a repeated answer, you would use 3,-1,-1,-1 as the repeat index.
The following Visual C# example uses SetRepeatIndex to add two names and e-mail addresses to an answer file:
public class ExampleCode { static void Main() { HotDocs.AnswerCollection asc = new HotDocs.AnswerCollection(); HotDocs.Answer ans = new HotDocs.Answer(); asc.Create(@"C:\Documents\HotDocs\Answers\AnswerFile.anx"); asc.FileFormat = HotDocs.HDAFFORMAT.HD2009Format; HotDocs.HDVARTYPE vType = HotDocs.HDVARTYPE.HD_TEXTTYPE; ans = asc.Item("Name", ref vType); ans.SetRepeatIndex(0, -1, -1, -1); ans.Value = "John"; asc.Add(ans); ans = asc.Item("Email", ref vType); ans.SetRepeatIndex(0, 0, -1, -1); ans.Value = "John@beatles.com"; asc.Add(ans); ans = asc.Item("Name", ref vType); ans.SetRepeatIndex(1, -1, -1, -1); ans.Value = "Paul"; asc.Add(ans); ans = asc.Item("Email", ref vType); ans.SetRepeatIndex(1, 0, -1, -1); ans.Value = "Paul@beatles.com"; asc.Add(ans); asc.Save(@"C:\Documents\HotDocs\Answers\AnswerFile.anx"); asc.Close(); ans = null; asc = null; } }