combobox select action

combobox select action

Anonymous
Not applicable
931 Views
8 Replies
Message 1 of 9

combobox select action

Anonymous
Not applicable

I have added a combobox named  m_pipeworkComboxDefinition to my custom panel in my addin,

Can someone help me with how to trigger a sub when it's value is changed?

 

Thanks in advance.

0 Likes
Accepted solutions (2)
932 Views
8 Replies
Replies (8)
Message 2 of 9

Owner2229
Advisor
Advisor
Accepted solution

Hi, I suppose you're working in VB.Net as you haven't stated else, so:

 

Somewhere in your form initialization (or in StandardAddInServer.vb > 'Activate' for the Ribbon panel) paste this line:

 

AddHandler Me.m_pipeworkComboxDefinition.TextChanged, AddressOf Me.MyComboChange

Then you can add the referenced Sub:

 

Sub MyComboChange
    MsgBox("Tada, it works!")
End Sub

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 9

Anonymous
Not applicable

Hi,

Thanks for the quick reply.

I tried adding your code as suggested but no luck.

 

I suppose I should've said this at the start:

This is the code (taken from the simpleaddin sample) that am using to generate my combobox:

 

#Region "Data Members"

        'combo-boxes
        Private m_pipeworkComboxDefinition As ComboBoxDefinition
   
#End Region

 

Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

                'create the comboboxes
                m_pipeworkComboxDefinition = InvApp.CommandManager.ControlDefinitions.AddComboBoxDefinition _
                 ("Pipework", "Autodesk:MyAssemblyTools:PipeMatCboBox", CommandTypesEnum.kShapeEditCmdType, 200, addInCLSIDString, _
                  "Select Which Piping Material To Use", "Piping Material")
       
                'add some initial items to the comboboxes
                m_pipeworkComboxDefinition.AddItem("Carbon Steel", 0)
                m_pipeworkComboxDefinition.AddItem("Low Temp Carbon Steel", 1)
                m_pipeworkComboxDefinition.AddItem("Stainless Steel", 2)



'##################



       ' add the combo boxes to the Tube and pipe tab panel panel
                        Dim PipeworkCmdCboBoxCmdCtrl As CommandControl
                        PipeworkCmdCboBoxCmdCtrl = parttubeandpipeRibbonPanelCtrls.AddComboBox(m_pipeworkComboxDefinition, "", False)


end sub

 

When I added in your code in it highlighted the .TextChanged part with the error:

'TextChanged' is not a member of 'Inventor.ComboboxDefinition'

 

 

 

0 Likes
Message 4 of 9

Jef_E
Collaborator
Collaborator

EDIT: bad post..



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 5 of 9

Anonymous
Not applicable

I don't follow,

My addin is a combobox that I've added to a new ribbon panel I've created.

I declared the combobox using the simpleaddin sample as a roadmap.

What other methods are there to declare a combobox?

 

Ta,

 

0 Likes
Message 6 of 9

Jef_E
Collaborator
Collaborator

Sorry, I should have read your code better.. I thought it was a combo-box on a windows form.. Still little bit sleepy? 😄



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 7 of 9

Owner2229
Advisor
Advisor
Accepted solution

Alright, since it is Inventor's ComboBoxDefinition, you can try this:

 

AddHandler Me.m_pipeworkComboxDefinition.OnSelect, AddressOf Me.MyComboChange

Place it at the end of your Activate Sub.

... and don't forget to add the "MyComboChange" Sub again.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 8 of 9

Anonymous
Not applicable
Fantastic!!
Working perfectly now.

many thanks.
0 Likes
Message 9 of 9

Owner2229
Advisor
Advisor

You're welcomed Smiley Happy

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes