Component in Toolbox

B

BluDog

Hi

I have a component that inherits from TreeView, my project is a
standard exe. How do i get the component into the toolbox for use
within the project?

I find that only controls based on UserControl apear there
automatically, therefore if i set the component to inherit from
UserControl it will appear, then i change it back to inherit from
TreeView, although it stays, as soon as i close the solition, the next
time i open it the component has gone.

Cheers

Blu
 
K

Ken Tucker [MVP]

Hi,

Add a reference to envdte. This app will add all the controls in
the vbpowerpack to a tab named vb power pack. Hope this helps.


Dim myDTE As EnvDTE.DTE

Dim objToolbox As ToolBox

Dim colTbxTabs As ToolBoxTabs

Dim objTab As ToolBoxTab

Dim colTbxItems As ToolBoxItems

Dim objTbxItem As ToolBoxItem

'

' Open the ide

'

myDTE =
CType(Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE.7.1"),
DTE)

' Create an object reference to the IDE's ToolBox object.

objToolbox = CType(myDTE.Windows.Item(Constants.vsWindowKindToolbox).Object,
ToolBox)

colTbxTabs = objToolbox.ToolBoxTabs

' look to see if tab exists

Dim bFound As Boolean = False

Dim tbtDelete As ToolBoxTab

For Each t As ToolBoxTab In colTbxTabs



If t.Name = "VB Power Pack" Then

tbtDelete = t

bFound = True

End If



Next

'

' Add tab if needed

'

If bFound Then tbtDelete.Delete()

objTab = colTbxTabs.Add("VB Power Pack")

objTab.Activate()

objTab.ToolBoxItems.Add("Control", AppPath() & "\vbPowerPack.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)

Trace.WriteLine(AppPath)

Timer1.Enabled = True

myDTE.Quit()



Ken
---------------------
Hi

I have a component that inherits from TreeView, my project is a
standard exe. How do i get the component into the toolbox for use
within the project?

I find that only controls based on UserControl apear there
automatically, therefore if i set the component to inherit from
UserControl it will appear, then i change it back to inherit from
TreeView, although it stays, as soon as i close the solition, the next
time i open it the component has gone.

Cheers

Blu
 
G

Guest

I have the similar problem. Adding a text format item to toolbox has no issue, but adding a custom control then it fails.

//succeed.
objTbxItem = objTab. _
ToolBoxItems. _
Add("New Text Item", "Some text to add to the document.",
vsToolBoxItemFormat.vsToolBoxItemFormatText)

// this fails
objTbxItem = objTab. _
ToolBoxItems. _
Add("ui_menu", "c:\ui_menu.dll", vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
 
K

Ken Tucker [MVP]

Hi,

Make sure you activate the tab before adding controls to it.

Ken
----------------
I have the similar problem. Adding a text format item to toolbox has no
issue, but adding a custom control then it fails.

//succeed.
objTbxItem = objTab. _
ToolBoxItems. _
Add("New Text Item", "Some text to add to the
document.",
vsToolBoxItemFormat.vsToolBoxItemFormatText)

// this fails
objTbxItem = objTab. _
ToolBoxItems. _
Add("ui_menu", "c:\ui_menu.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top