IToolboxUser.GetToolSupported 方法

获取一个值,该值指示当前设计器是否支持指定工具。

**命名空间:**System.Drawing.Design
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Function GetToolSupported ( _
    tool As ToolboxItem _
) As Boolean
用法
Dim instance As IToolboxUser
Dim tool As ToolboxItem
Dim returnValue As Boolean

returnValue = instance.GetToolSupported(tool)
bool GetToolSupported (
    ToolboxItem tool
)
bool GetToolSupported (
    ToolboxItem^ tool
)
boolean GetToolSupported (
    ToolboxItem tool
)
function GetToolSupported (
    tool : ToolboxItem
) : boolean

参数

  • tool
    要进行工具箱支持测试的 ToolboxItem

返回值

如果工具箱支持该工具而且该工具可启用,则为 true;如果该文档设计器不知道如何使用该工具,则为 false

备注

如果实现 IToolboxUser 接口的设计器支持指定的工具,那么当此设计器被选中时将在工具箱中启用该工具。否则将被禁用。某个工具标记为启用或禁用后,无法再次对其进行同一设计器的支持测试。

示例

下面的代码示例演示 GetToolSupported 方法的实现。

' This method can signal whether to enable or disable the specified
' ToolboxItem when the component associated with this designer is selected.
Function GetToolSupported(ByVal tool As ToolboxItem) As Boolean Implements IToolboxUser.GetToolSupported
    ' Search the blocked type names array for the type name of the tool
    ' for which support for is being tested. Return false to indicate the
    ' tool should be disabled when the associated component is selected.
    Dim i As Integer
    For i = 0 To blockedTypeNames.Length - 1
        If tool.TypeName = blockedTypeNames(i) Then
            Return False
        End If
    Next i ' Return true to indicate support for the tool, if the type name of the
    ' tool is not located in the blockedTypeNames string array.
    Return True
End Function
// This method can signal whether to enable or disable the specified
// ToolboxItem when the component associated with this designer is selected.
bool IToolboxUser.GetToolSupported(ToolboxItem tool)
{       
    // Search the blocked type names array for the type name of the tool
    // for which support for is being tested. Return false to indicate the
    // tool should be disabled when the associated component is selected.
    for( int i=0; i<blockedTypeNames.Length; i++ )
        if( tool.TypeName == blockedTypeNames[i] )
            return false;
    
    // Return true to indicate support for the tool, if the type name of the
    // tool is not located in the blockedTypeNames string array.
    return true;
}

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

IToolboxUser 接口
IToolboxUser 成员
System.Drawing.Design 命名空间
ToolboxItem