Enable or disable buttons in VB.NET

Enable or disable buttons in VB.NET

martin_mmj
Enthusiast Enthusiast
789 Views
3 Replies
Message 1 of 4

Enable or disable buttons in VB.NET

martin_mmj
Enthusiast
Enthusiast
My addin was written in VB.NET/VisualStudio 2008. I created my own CommandBar with a few buttons. Works fine, but I don't know how to enable/disable my buttons depending on type of documents by VB.NET.

For example: How to enable my buttons on my panel only in IDW drawings and disable it in other type of documents?

Can you help me? Exists any sample?

Thanks Martin
0 Likes
790 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi,

i dosent show the panels for each documenttype
for the ZeroDoc i dosent show the tools panel

panel_support.CommandControls.AddButton(oButtonDefinition1, True)
panel_support.CommandControls.AddButton(oButtonDefinition2, True)
panel_support.CommandControls.AddButton(oButtonDefinition3, True)
panel_info.CommandControls.AddButton(oButtonDefinition5, True)

for the PartDoc i show the tools panel

part_panel_support.CommandControls.AddButton(oButtonDefinition1, True)
part_panel_support.CommandControls.AddButton(oButtonDefinition2, True)
part_panel_support.CommandControls.AddButton(oButtonDefinition3, True)
part_panel_tools.CommandControls.AddButton(oButtonDefinition4, True)
part_panel_info.CommandControls.AddButton(oButtonDefinition5, True)

another way is you create a new button with the same function
and enabled = false the Button

hope i help you

Mario
0 Likes
Message 3 of 4

Anonymous
Not applicable
If you only want it to be enabled in IDW documents, you can do something like this inside your addin class.

{code}

Private WithEvents m_objApplicationEvents As ApplicationEvents

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

m_objInventorApplication = addInSiteObject.Application
m_objApplicationEvents = m_objInventorApplication.ApplicationEvents

'Your other activation stuff
...
End Sub

Private Sub m_objApplicationEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_objApplicationEvents.OnActivateDocument
If BeforeOrAfter = EventTimingEnum.kAfter Then
If DocumentObject.FullFileName.ToUpper.EndsWith(".IDW") Then
'Enable your buttons
Else
'Disable your buttons
End if
End If
End Sub
{code}
0 Likes
Message 4 of 4

Anonymous
Not applicable
you might also look at the Environment.DisabledCommandList
0 Likes