By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Component in Toolbox

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.CreateObje ct("VisualStudio.DTE.7.1"),
DTE)

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

objToolbox = CType(myDTE.Windows.Item(Constants.vsWindowKindToo lbox).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.vsToolBoxItemFormatDotNETCompo nent)

Trace.WriteLine(AppPath)

Timer1.Enabled = True

myDTE.Quit()

Ken
---------------------
"BluDog" <ne**@nospam.bludog.net> wrote in message
news:et********************************@4ax.com...
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
Nov 20 '05 #2

P: n/a
JC
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.vsToolBoxItemFormatDotNETCompo nent)

"Ken Tucker [MVP]" wrote:
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.CreateObje ct("VisualStudio.DTE.7.1"),
DTE)

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

objToolbox = CType(myDTE.Windows.Item(Constants.vsWindowKindToo lbox).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.vsToolBoxItemFormatDotNETCompo nent)

Trace.WriteLine(AppPath)

Timer1.Enabled = True

myDTE.Quit()

Ken
---------------------
"BluDog" <ne**@nospam.bludog.net> wrote in message
news:et********************************@4ax.com...
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

Nov 20 '05 #3

P: n/a
Hi,

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

Ken
----------------
"JC" <JC@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
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.vsToolBoxItemFormatDotNETCompo nent)

"Ken Tucker [MVP]" wrote:
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.CreateObje ct("VisualStudio.DTE.7.1"),
DTE)

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

objToolbox =
CType(myDTE.Windows.Item(Constants.vsWindowKindToo lbox).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.vsToolBoxItemFormatDotNETCompo nent)

Trace.WriteLine(AppPath)

Timer1.Enabled = True

myDTE.Quit()

Ken
---------------------
"BluDog" <ne**@nospam.bludog.net> wrote in message
news:et********************************@4ax.com...
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

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.