This documentation is archived and is not being maintained.

Activate Method (General Extensibility)

Visual Studio .NET 2003

Moves the focus to the current item and makes it active.

[Visual Basic .NET]
Public Sub Activate() 
[Visual Basic 6]
Sub Activate() 
[C++]
HRESULT __stdcall Activate();
[C#]
void Activate();
[JScript .NET]
public function Activate()

Remarks

When Activate is invoked, it is as if the user clicked on the item, but no click events occur.

For the ToolBoxTab object, Activate operates on Toolbox tabs, which differs from the Select method which operates on Toolbox items.

Example

The following code deletes the selected Toolbox item:

Sub ActivateExample()
   Dim objToolbox As ToolBox
   Dim colTbxTabs As ToolBoxTabs
   Dim objTab As ToolBoxTab
   Dim colTbxItems As ToolBoxItems
   Dim objTbxItem As ToolBoxItem

   ' Create references to the IDE's ToolBox object and ToolBoxTabs 
   ' collection.
   objToolbox = DTE.Windows.Item(Constants.vsWindowKindToolbox).Object
   colTbxTabs = objToolbox.ToolBoxTabs
   objTab = colTbxTabs.Item(1)
   colTbxItems = objTab.ToolBoxItems

   ' Add a new tab to the ToolBox.
   objTab = colTbxTabs.Add("Sample ToolBoxTab")

   ' Add a couple of new ToolboxItem objects to the new tab we just added.
   objTbxItem = objTab.ToolBoxItems.Add("Text Item", "Hello world")
   objTbxItem = objTab.ToolBoxItems.Add("HTML Item", "Hello world", vsToolBoxItemFormat.vsToolBoxItemFormatHTML)

   ' Select the third item on the newly-created tab in the Toolbox and 
   ' delete it.
   colTbxTabs.Item(1).Activate()
   colTbxItems.Item(3).Select()
   If (MsgBox("Delete the selected ToolBox item?", vbYesNo) = vbYes) Then
      colTbxItems.SelectedItem.Delete()
   End If
End Sub

See Also

Applies To: Document Object | OutputWindowPane Object | SolutionConfiguration Object | TextPane Object | ToolBoxTab Object | Window Object

Show: