IToolboxUser.GetToolSupported(ToolboxItem) Méthode

Définition

Obtient une valeur indiquant si l'outil spécifié est pris en charge par le concepteur actuel.

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

Paramètres

tool
ToolboxItem

ToolboxItem dont la prise en charge de la boîte à outils est à vérifier.

Retours

Boolean

true si l'outil est pris en charge par la boîte à outils et s'il peut être activé ; false si le Concepteur de documents n'est pas capable d'utiliser l'outil.

Exemples

L’exemple de code suivant illustre une implémentation de la GetToolSupported méthode.

// 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

Remarques

Si l’outil spécifié est pris en charge par le concepteur qui implémente l’interface IToolboxUser , l’outil est activé dans la boîte à outils lorsque ce concepteur a le focus. Sinon, elle sera désactivée. Une fois qu’un outil est marqué comme activé ou désactivé, il peut ne pas être testé pour la prise en charge avec le même concepteur.

S’applique à

Voir aussi