ToolStripButton How-To

Learn how to create Add-Ins of all types for V3-R and share your own tutorials with others.
1 post Page 1 of 1
Contributors
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

ToolStripButton How-To
CodenStuff
Hello,

In this tutorial I will quickly show you how to create an Add-In which displays a button in the bottom toolstrip of V3-R.

Ok the first thing you need to do is start a new project and add the AppGlue class file code as normal.

Then we need to add a new Class file to our project and call it 'MyButton'

Now lets add our code to the MyButton class file:
Code: Select all
Imports System.Windows.Forms

Public Class Mybutton
    Inherits ToolStripButton
End Class

That was easy but now we need to give our button an image otherwise it wont look very good so add an image resource to your project and alter your MyButton code as follows:
Code: Select all
Imports System.Windows.Forms

Public Class Mybutton
    Inherits ToolStripButton

    Sub New()
        Me.Image = My.Resources.NameOfImageResource
    End Sub

End Class

Now we have our button made but its not much use to us unless it does something when you click it. So lets alter our code again and add a click event to our button which will display a message box on click:
Code: Select all
Imports System.Windows.Forms

Public Class Mybutton
    Inherits ToolStripButton

    Private Sub MyButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        MsgBox("You clicked me!")
    End Sub

    Sub New()
        Me.Image = My.Resources.NameOfImageResource
    End Sub

End Class
You can use the click event to do anything you want like display a form, run code in the background, display a message box etc. Our button is now complete so lets goto our AppGlue class file and make some small changes to our settings.

First locate the "ToolStripButton" setting and uncomment the MyButton code on the end like this:
Code: Select all
Private ToolStripButton As ToolStripItem = New Mybutton
Then we need to tell V3-R that its a button we are adding so change the "iLocation" setting to 3 like this:
Code: Select all
Private iLocation As String = 3
And thats it..we are finished!.

Compile/Build the code and test it out in V3-R.


So now you know how to add a toolstripbutton to V3-R you can get on and create some great Add-Ins cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
1 post Page 1 of 1
Return to “Tutorials”