IToolboxUser.GetToolSupported(ToolboxItem) Метод

Определение

Возвращает значение, определяющее, поддерживается ли указанное средство текущим конструктором.Gets a value indicating whether the specified tool is supported by the current designer.

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.The ToolboxItem to be tested for toolbox support.

Возвращаемое значение

Boolean

true, если средство поддерживается панелью элементов и может быть включено; значение false, если конструктор документа не знает, как использовать это средство.true if the tool is supported by the toolbox and can be enabled; false if the document designer does not know how to use the tool.

Примеры

В следующем примере кода демонстрируется реализация GetToolSupported метода.The following code example demonstrates an implementation of the GetToolSupported method.

// 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 интерфейс, то средство будет включено на панели элементов, если этот конструктор имеет фокус.If the specified tool is supported by the designer implementing the IToolboxUser interface, then the tool will be enabled in the toolbox when this designer has focus. В противном случае он будет отключен.Otherwise, it will be disabled. После того как средство помечено как включенное или отключенное, оно может еще не проверяться на поддержку этого же конструктора.Once a tool is marked as enabled or disabled, it may not be tested for support with the same designer again.

Применяется к

См. также раздел