DTE-Eigenschaftsauflistungen
Aktualisiert: November 2007
The environment-level properties are organized into categories that correspond to the hierarchy displayed in the Options dialog box. To see the Options dialog box, on the Tools menu, click Options. For the sake of simplicity, this topic refers to this dialog box as the Tools Options dialog box. For example, DTE.Properties("TextEditor", "Basic") represents the settings in the Basic node within the Text Editor node in the Tools Options dialog box. Many times, the settings in the dialog boxes are also represented by properties. For example, one setting in the Tabs, Basic, Text Editor, Options dialog box is Tab size. This is represented by the TabSize and TabSize properties. Each property item has one or more values, represented by the Value property. For information about how to change options values by using properties, see Steuern der Einstellungen im Dialogfeld "Optionen" (Menü "Extras").
The topics in the See Also section below list the predefined categories that come with Visual Studio. However, Visual Studio packages can add their own categories (Tools Options pages), and you can create your own custom Tools Options pages.
Hinweis: |
---|
Some property pages in the Options dialog box do not support automation. The property pages that do support automation are listed in Bestimmen der Namen von Eigenschaftenelementen auf Optionsseiten im Menü "Extras". |
The same Properties collection object can be accessed in different locations. For example, a properties collection for fonts and colors might be accessed with either DTE.Properties("Environment", "FontsAndColors") or DTE.Properties("TextEditor", "FontsAndColors").
Beispiel
The following example illustrates how to view all accessible property items in the General, C#, Text Editor, Options dialog box. Note that in code, the "C#" node must be represented as "CSharp." For more information about how to run the Add-in example, see Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.
' Add-in code.
Public Sub OnConnection(ByVal application As Object, ByVal connectMode _
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef _
custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
applicationObject = CType(application, EnvDTE.DTE)
addInInstance = CType(addInInst, EnvDTE.AddIn)
' Pass the applicationObject member variable to the code example.
PropertiesExample (applicationObject)
End Sub
Sub PropertiesExample(ByVal dte As DTE)
' Create and initialize a variable to represent the C#
' text editor options page.
Dim txtEdCS As EnvDTE.Properties = _
DTE.Properties("TextEditor", "CSharp")
Dim prop As EnvDTE.Property
Dim msg As String
' Loop through each item in the C# text editor options page.
For Each prop In txtEdCS
msg += ("PROP NAME: " & prop.Name & " VALUE: " & _
prop.Value) & vbCr
Next
MsgBox(msg)
End Sub
// Add-in code.
Using System.Windows.Forms;
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst,
ref System.Array custom)
{
applicationObject = (_DTE)application;
addInInstance = (AddIn)addInInst;
// Pass the applicationObject member variable to the code example.
PropertiesExample((DTE)applicationObject);
}
public void PropertiesExample( DTE dte )
{
// Create and initialize a variable to represent the C#
// text editor options page.
EnvDTE.Properties txtEdCS =
dte.get_Properties( "TextEditor", "CSharp" );
EnvDTE.Property prop = null;
string msg = null;
// Loop through each item in the C# text editor options page.
foreach ( EnvDTE.Property temp in txtEdCS )
{
prop = temp;
msg += ( "PROP NAME: " + prop.Name + " VALUE: "
+ prop.Value ) + "\n";
}
MessageBox.Show( msg);
}
A slight modification to the previous code allows you to view the options of a nested node, in the following case, the Formatting, C#, Text Editor, Options page. You do this by changing the second Properties parameter value to the options you want to view or change, such as DTE.Properties("TextEditor", "Basic - Tabs"), or DTE.Properties("Environment", "Help - Online"). The values to use are listed at the beginning of this topic.
This case uses "CSharp - Formatting" to view the Formatting options settings for the C# Text Editor.
' Add-in code.
Sub PropertiesExample()
' Create and initialize a variable to represent the C#
' Formatting text editor options page.
Dim txtEdCSFormat As EnvDTE.Properties = _
DTE.Properties("TextEditor", "CSharp - Formatting")
Dim prop As EnvDTE.Property
Dim msg As String
' Loop through each item in the C# Formatting Options page.
For Each prop In txtEdCSFormat
msg += ("PROP NAME: " & prop.Name & " VALUE: " & _
prop.Value) & vbCr
Next
MsgBox(msg)
End Sub
Siehe auch
Aufgaben
Gewusst wie: Erstellen benutzerdefinierter Optionsseiten im Menü "Extras"
Konzepte
Steuern der Einstellungen im Dialogfeld "Optionen" (Menü "Extras")
Bestimmen der Namen von Eigenschaftenelementen auf Optionsseiten im Menü "Extras"
Optionsseite, Eigenschaften des Knotens "Umgebung"
Optionsseite, Eigenschaften des Knotens "Schriftarten und Farben"
Optionsseite, Eigenschaften des Knotens "Text-Editor"