ComponentCollection.Count Property

[Read-only] This property returns the number of Component objects in the ComponentCollection.

Syntax

int Count [ get ]

Example

The following Visual C# example displays a list of all variable components in a given component file.

public class ExampleCode
{
    static void Main()
    {
        HotDocs.ComponentCollection ccl = new HotDocs.ComponentCollection();
        string msg;
         
        ccl.Open(@"C:\Documents\HotDocs\Templates\demoempl.cmp");
         
        for (int i = 1; i < ccl.Count; i++)
        {
            msg = ccl.Item(i).Name + " - ";
            switch (ccl.Item(i).Type)
            {
                case HDVARTYPE.HD_TEXTTYPE:
                    Console.WriteLine(msg + " Text Variable");
                    break;
                case HDVARTYPE.HD_NUMBERTYPE:
                    Console.WriteLine(msg + " Number Variable");
                    break;
                case HDVARTYPE.HD_DATETYPE:
                    Console.WriteLine(msg + " Date Variable");
                    break;
                case HDVARTYPE.HD_TRUEFALSETYPE:
                    Console.WriteLine(msg + " True/False Variable");
                    break;
                case HDVARTYPE.HD_MULTCHOICETYPE:
                    Console.WriteLine(msg + " Multiple Choice Variable");
                    break;
                case HDVARTYPE.HD_COMPUTATIONTYPE:
                    Console.WriteLine(msg + " Computation Variable");
                    break;
            }
        }
        Console.ReadKey();
    }
}