Forms2OleControl

Forms2OleControl class

表示 Microsoft Forms 2.0 OLE 控件。

要了解更多信息,请访问使用 Ole 对象文档文章。

public abstract class Forms2OleControl : OleControl

特性

姓名描述
BackColor { get; set; }获取或设置控件的背景颜色。 默认值取决于控件的类型。
Caption { get; set; }获取或设置控件的 Caption 属性。 默认值为空字符串。
virtual ChildNodes { get; }获取直接子控件的集合。
Enabled { get; }返回真的如果控制处于启用状态。
ForeColor { get; set; }获取或设置控件的前景色。 默认值取决于控件的类型。
GroupName { get; set; }获取或设置指定一组互斥控件的字符串。 默认值为空字符串。
Height { get; set; }获取或设置控件的高度(以点为单位)。
IsForms2OleControl { get; }返回真的如果控件是Forms2OleControl.
Name { get; set; }获取或设置 ActiveX 控件的名称。
abstract Type { get; }获取 Forms 2.0 控件的类型。
Value { get; }获取通常代表控制状态的底层 Value 属性。 例如,选中的选项按钮的值为“1”,而未选中的选项按钮的值为“0”。 默认值为空字符串。
Width { get; set; }获取或设置控件的宽度(以点为单位)。

例子

展示如何验证 ActiveX 控件的属性。

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

Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
OleControl oleControl = shape.OleFormat.OleControl;

Assert.AreEqual("CheckBox1", oleControl.Name);

if (oleControl.IsForms2OleControl)
{
    Forms2OleControl checkBox = (Forms2OleControl)oleControl;
    Assert.AreEqual("First", checkBox.Caption);
    Assert.AreEqual("0", checkBox.Value);
    Assert.AreEqual(true, checkBox.Enabled);
    Assert.AreEqual(Forms2OleControlType.CheckBox, checkBox.Type);
    Assert.AreEqual(null, checkBox.ChildNodes);
    Assert.AreEqual(string.Empty, checkBox.GroupName);

    // 请注意,您不能为 Frame 设置 GroupName。
    checkBox.GroupName = "Aspose group name";
}

也可以看看