IInfoPathViewControl Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a control present in the view.
public interface class IInfoPathViewControl
[System.Runtime.InteropServices.Guid("096CD6DA-0786-11D1-95FA-0080C78EE3BB")]
[System.Runtime.InteropServices.InterfaceType(1)]
public interface IInfoPathViewControl
type IInfoPathViewControl = interface
Public Interface IInfoPathViewControl
- Attributes
Examples
In the following example, the Import method of the IInfoPathDataImporter interface is used to iterate through the mshtml.IEnumUnknown collection of IInfoPathViewControl controls in the view of the active form.
The Import routine is the main part of a solution used to build a custom data importer. The Visual Studio project requires a reference to the Microsoft Office InfoPath 2.0 Type Library and System.Windows.Forms, with Imports statements for each as well as mshtml.Implements statements are required to generate the signatures for the methods provided by the custom data importer interfaces, including IInfoPathDataImporter, IInfoPathDataImporterFields, IInfoPathViewControl, and IPropertyBag.
Note: To build a custom data importer using a .NET class library, check the Register for COM interop check box on the Compile tab of the class properties editor.
Note: To debug a custom data importer, set a Start Action in Visual Studio to Start an external program, and browse to INFOPATH.EXE located at <drive>:\Program Files\Microsoft Office\Office12\. This option is available on the Debug tab of the class properties editor.
Imports Microsoft.Office.Interop.InfoPath
Imports System.Windows.Forms
Imports mshtml
<ComClass(Class1.ClassId, Class1.InterfaceId, Class1.EventsId)> Public Class Class1
Implements Microsoft.Office.Interop.InfoPath.IInfoPathDataImporter
Implements Microsoft.Office.Interop.InfoPath.IInfoPathDataImporterFields
Implements Microsoft.Office.Interop.InfoPath.IInfoPathViewControl
Implements Microsoft.Office.Interop.InfoPath.IPropertyBag
Public Const ClassId As String = _
"1FEB0DF8-E7F1-4b21-A9EE-B06D5FECC572"
Public Const InterfaceId As String = _
"9F9F685C-71A0-46ec-A7F9-A86AF8CBC2A8"
Public Const EventsId As String = _
"ED7C0C49-3F89-40a2-A50E-C59E8F682B08"
Public Sub Import(
_ByVal pPrintSettings As Microsoft.Office.Interop.InfoPath.IPropertyBag, _
ByVal punkViewControls As mshtml.IEnumUnknown) _
Implements Microsoft.Office.Interop.InfoPath.IInfoPathDataImporter.Import
Dim pControl As IInfoPathViewControl
Dim pUnk As Object
Dim pcelt As UInt16 = 1
Dim pceltFetched As UInt16 = 0
Try
'Gets first control in the view
punkViewControls.RemoteNext(pcelt, pUnk, pceltFetched)
Do While pUnk.ToString() <> "Nothing"
pControl = pUnk
MessageBox.Show(pControl.ControlType)
'Gets next control in the view
punkViewControls.RemoteNext(pcelt, pUnk, pceltFetched)
Loop
Catch e As Exception
If e.Message = _
"Object reference not set to an instance of an object." Then
' Signals the end of the enumeration/controls in the view
Else
MessageBox.Show("Error: " & e.ToString & " " & e.Message)
End If
End Try
End Sub
Remarks
The IInfoPathViewControl interface, used in conjunction with the IInfoPathDataImporter interface, allows developers to get specific information about the controls in the view, such as the ControlType and the DataType, the Top and Left positions, the XML NodeName associated with the control, and the InputScopes(IntPtr, UInt32, IEnumString, String). The Value property is the only property that can be set.
For a list of controls that are enumerated if present in the view, see the GetControls(IEnumUnknown) method of the IInfoPathDataImporterFields interface. For a list of acceptable data types that can be used with specific controls, see the Value property of the IInfoPathViewControl interface.
For more information about programmatically importing data into an InfoPath form, see the InfoPath Developer PortalMicrosoft Office Developer Center.
Properties
ControlType |
Gets the control type of the current control in the enumeration. |
DataType |
Gets the data type of a control in the view. |
Height |
Gets the height of the current control in the enumeration. |
Left |
Gets the offset, from the left side of the view, of the current control in the enumeration. |
NodeName |
Gets the name of the node associated with the current control in the enumeration. |
Top |
Gets the offset, from the top of the view, of the current control in the enumeration. |
Value |
Gets or sets the value of the current control in the enumeration. |
Width |
Gets the width of the current control in the enumeration. |
Methods
InputScopes(IntPtr, UInt32, IEnumString, String) |
Gets the input scope of the current control in the enumeration. |