TextPattern.CapStyleAttribute Champ

Définition

Identifie l'attribut CapStyle d'une plage de texte.

C#
public static readonly System.Windows.Automation.AutomationTextAttribute CapStyleAttribute;

Valeur de champ

Exemples

L’exemple suivant montre comment obtenir une valeur d’attribut pour une plage de texte dans Microsoft Bloc-notes.

Remarque

Microsoft Bloc-notes est utilisé uniquement comme fournisseur de texte. Microsoft Bloc-notes ne prend pas en charge la valeur d’attribut demandée n’est pas garantie.

C#
private void GetCapStyleAttribute()
{
    // Start application.
    Process p = Process.Start("Notepad.exe", "text.txt");

    // target --> The root AutomationElement.
    AutomationElement target = AutomationElement.FromHandle(p.MainWindowHandle);

    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return;
    }

    Object oAttribute = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.CapStyleAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixed cap styles.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}

Remarques

Cet identificateur est utilisé par UI Automation applications clientes. UI Automation fournisseurs doivent utiliser le champ équivalent dans TextPatternIdentifiers.

UI Automation clients obtiennent la valeur de l’attribut en appelant GetAttributeValue.

Les valeurs de cet attribut sont de type CapStyle. La valeur par défaut est None.

S’applique à

Produit Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Voir aussi