Hide Table of Contents
AddToolbarCommand2 Method (ISldWorks)

Specifies the application functions to be called when a toolbar button is pressed or sets a separator.

.NET Syntax

Visual Basic (Declaration) 
Function AddToolbarCommand2( _
   ByVal Cookie As System.Integer, _
   ByVal ToolbarId As System.Integer, _
   ByVal ToolbarIndex As System.Integer, _
   ByVal ButtonCallback As System.String, _
   ByVal ButtonEnableMethod As System.String, _
   ByVal ToolTip As System.String, _
   ByVal HintString As System.String _
) As System.Boolean
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim Cookie As System.Integer
Dim ToolbarId As System.Integer
Dim ToolbarIndex As System.Integer
Dim ButtonCallback As System.String
Dim ButtonEnableMethod As System.String
Dim ToolTip As System.String
Dim HintString As System.String
Dim value As System.Boolean
value = instance.AddToolbarCommand2(Cookie, ToolbarId, ToolbarIndex, ButtonCallback, ButtonEnableMethod, ToolTip, HintString)
System.bool AddToolbarCommand2( 
   System.int Cookie,
   System.int ToolbarId,
   System.int ToolbarIndex,
   System.string ButtonCallback,
   System.string ButtonEnableMethod,
   System.string ToolTip,
   System.string HintString
System.bool AddToolbarCommand2( 
&   System.int Cookie,
&   System.int ToolbarId,
&   System.int ToolbarIndex,
&   System.String^ ButtonCallback,
&   System.String^ ButtonEnableMethod,
&   System.String^ ToolTip,
&   System.String^ HintString



Resource ID of the toolbar. This is the same Cookie you specified in ISwAddin::ConnectToSW


Toolbar ID from SldWorks::AddToolbar4


0-based index of the bitmap button


Function called when the user clicks the button (see Remarks)


Function called to check whether or not the button should be enabled; typically used to check the type of object selected (see Remarks)


ToolTip for the toolbar button


Text that SOLIDWORKS displays in the status bar when the user moves their mouse over this toolbar button

Return Value

True if successful, false if unsuccessful



See Add-in Callback and Enable Methods to learn how to specify ButtonCallback and ButtonEnableMethod.

Call this method to specify the functions that get called by the SOLIDWORKS software when the button is pressed and to check if the button is enabled. Until this method is called, the SOLIDWORKS software does not display the button.

If ButtonEnableMethod returns...



Deselects and disables the menu item


Deselects and enables the menu item; this is the default menu state if no update function is specified


Selects and disables the menu item


Selects and enables the menu item

To create a separator, all of the method's string parameters (ButtonCallback, ButtonEnableMethod, ToolTip, and HintString) must be blank strings. A bitmap button must still be defined in the add-in's resources, but it will not be used.


See Also


SOLIDWORKS 2001Plus FCS, Revision Number 10.0

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   AddToolbarCommand2 Method (ISldWorks)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.