Forms2OleControlCollection

Forms2OleControlCollection class

Representerar samling avForms2OleControl objekt.

För att lära dig mer, besökArbeta med Ole Objects dokumentationsartikel.

public class Forms2OleControlCollection : IEnumerable<Forms2OleControl>

Konstruktörer

namnBeskrivning
Forms2OleControlCollection()Default_Constructor

Egenskaper

namnBeskrivning
Count { get; }Får antalet objekt i samlingen.
Item { get; }BlirForms2OleControl objekt vid ett angivet index.

Metoder

namnBeskrivning
GetEnumerator()Får enumerator.

Exempel

Visar hur man kommer åt en OLE-kontroll inbäddad i ett dokument och dess underordnade kontroller.

Document doc = new Document(MyDir + "OLE ActiveX controls.docm");

// Former lagrar och visar OLE-objekt i dokumentets kropp.
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);

Assert.AreEqual("6e182020-f460-11ce-9bcd-00aa00608e01", shape.OleFormat.Clsid.ToString());

Forms2OleControl oleControl = (Forms2OleControl)shape.OleFormat.OleControl;

// Vissa OLE-kontroller kan innehålla underordnade kontroller, till exempel den i detta dokument med tre alternativknappar.
Forms2OleControlCollection oleControlCollection = oleControl.ChildNodes;

Assert.AreEqual(3, oleControlCollection.Count);

Assert.AreEqual("C#", oleControlCollection[0].Caption);
Assert.AreEqual("1", oleControlCollection[0].Value);

Assert.AreEqual("Visual Basic", oleControlCollection[1].Caption);
Assert.AreEqual("0", oleControlCollection[1].Value);

Assert.AreEqual("Delphi", oleControlCollection[2].Caption);
Assert.AreEqual("0", oleControlCollection[2].Value);

Se även