Button.OLEType 属性

获取一个值,该值表示 OLE 对象类型。

命名空间:  Microsoft.Office.Tools.Excel.Controls
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property OLEType As Object
    Get
public Object OLEType { get; }

属性值

类型:System.Object
一个 xlOLEControl

示例

下面的代码示例创建一个 Button 控件,并将一个描述该按钮的 OLE 对象类型的字符串指定为按钮文本,OLE 对象类型由 OLEType 属性值确定。

此示例针对的是文档级自定义项。

Private Sub DisplayOLEType()
    Dim OleButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "OleButton1")

    Dim ControlType As String
    Select Case OleButton.OLEType
        Case Excel.XlOLEType.xlOLEControl
            ControlType = "OLE control"

        Case Excel.XlOLEType.xlOLEEmbed
            ControlType = "OLE embedded control"

        Case Excel.XlOLEType.xlOLELink
            ControlType = "OLE linked control"

        Case Else
            ControlType = "Not assigned an OLE type"
    End Select
    oleButton.Text = controlType
End Sub
private void DisplayOLEType()
{
    Microsoft.Office.Tools.Excel.Controls.Button oleButton =
            this.Controls.AddButton(this.Range["B2", "C3"],
            "oleButton1");

    string controlType;
    switch ((int)oleButton.OLEType)
    {
        case (int)Excel.XlOLEType.xlOLEControl:
            controlType = "OLE control";
            break;

        case (int)Excel.XlOLEType.xlOLEEmbed:
            controlType = "OLE embedded control";
            break;

        case (int)Excel.XlOLEType.xlOLELink:
            controlType = "OLE linked control";
            break;

        default:
            controlType = "Not assigned an OLE type";
            break;
    }
    oleButton.Text = controlType;
}

.NET Framework 安全性

请参见

参考

Button 类

Microsoft.Office.Tools.Excel.Controls 命名空间