TextPattern.IsReadOnlyAttribute Campo

Definizione

Identifica l'attributo IsReadOnly di un intervallo di testo.

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

Valore del campo

Esempio

Nell'esempio seguente viene illustrato come ottenere un valore di attributo per un intervallo di testo in Microsoft Blocco note.

Nota

Microsoft Blocco note viene usato solo come provider di testo. Microsoft Blocco note non è garantito supportare il valore dell'attributo richiesto.

C#
private void GetIsReadOnlyAttribute()
{
    // 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.IsReadOnlyAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixture of readonly and non-readonly.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}

Commenti

Questo attributo rappresenta lo stato di sola lettura del documento associato all'intervallo di testo chiamante.

Nota

Se un documento o un file è di sola lettura, ma è comunque possibile modificarlo e salvarlo come un altro file, il testo non viene considerato di sola lettura.

Questo identificatore viene usato da Automazione interfaccia utente applicazioni client. Automazione interfaccia utente provider devono usare il campo equivalente in TextPatternIdentifiers.

Automazione interfaccia utente client ottengono il valore dell'attributo chiamando GetAttributeValue.

I valori per questo attributo sono di tipo Boolean. Il valore predefinito è false.

Si applica a

Prodotto Versioni
.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

Vedi anche