ControlID Property [Office 2003 SDK Documentation]
The ControlID property specifies a unique control number that each of the methods in the Smart Document API uses to refer to the controls in the smart document.
Applies to
Syntax
[Visual Basic 6.0]
Private Property Get ISmartDocument_ControlID(ByVal XMLTypeName As String, ByVal ControlIndex As Long) As Long
[Visual Basic .NET]
Public ReadOnly Property ControlID(ByVal XMLTypeName As String, ByVal ControlIndex As Integer) As Integer Implements Microsoft.Office.Interop.SmartTag.ISmartDocument.ControlID
[C#]
public int ISmartDocument.get_ControlID(string XMLTypeName, int ControlIndex)
[Visual C++ 6.0]
STDMETHOD(get_ControlID)(BSTR XMLTypeName, INT ControlIndex, INT * ControlID)
[Visual C++ .NET]
STDMETHOD(get_ControlID)(BSTR XMLTypeName, int ControlIndex, int * ControlID)
Parameters
XMLTypeName Represents the name of the XML element as defined in the SmartDocXmlTypeName property.
ControlIndex The number assigned to a smart document control. This is an index that is numbered from 1 to the value defined in the ****
Visit ControlCount
property for a specific XML element as defined in the SmartDocXMLTypeName property.
Remarks
The ControlIndex value provides a number that represents a control's position in the collection of controls for an XML element. However, each control collection starts numbering the controls at 1, which means that if you have multiple elements that have multiple controls, there will be multiple controls with the same ControlIndex value. For example, if you have two elements, one with two controls and another with two controls, the ControlIndex values for the first element would be 1 and 2, and the ControlIndex values for the second element would also be 1 and 2. Therefore, the ControlID property allows you to assign a unique number to a control or a set of controls.
The best way to provide a unique ControlID value for each control is to add a number to the ControlIndex for each type. This new value becomes the value of the ControlID property, which is passed into other methods and properties as the ControlID parameter. The following two examples show how you can do this by using a Select Case statement in Microsoft Visual Basic and a switch statement in C#.
Visual Basic example
Select Case XMLTypeName
Case cTEXTBOX
ISmartDocument_ControlID = ControlIndex
Case cCOMMANDBUTTON
ISmartDocument_ControlID = ControlIndex + 100
End Select
C# example
switch(XMLTypeName)
{
case cTEXTBOX:
ControlID = ControlIndex;
case cCOMMANDBUTTON:
ControlID = ControlIndex + 100;
default:
}