IToolboxUser.GetToolSupported(ToolboxItem) 方法

定义

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

public:
 bool GetToolSupported(System::Drawing::Design::ToolboxItem ^ tool);
public bool GetToolSupported (System.Drawing.Design.ToolboxItem tool);
abstract member GetToolSupported : System.Drawing.Design.ToolboxItem -> bool
Public Function GetToolSupported (tool As ToolboxItem) As Boolean

参数

tool
ToolboxItem

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

返回

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

示例

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

// 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;
}
// 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;
}
' 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

注解

如果实现 IToolboxUser 接口的设计器支持指定的工具,则当此设计器具有焦点时,将在工具箱中启用该工具。 否则,它处于禁用状态。 工具标记为启用或禁用后,可能无法再次通过同一设计器对其进行支持测试。

适用于

另请参阅