How to add tool bar in vb.net




















Contents Exit focus mode. Please rate your experience Yes No. Any additional feedback? Note The ToolStrip control replaces and adds functionality to the ToolBar control; however, the ToolBar control is retained for both backward compatibility and future use, if you choose. Submit and view feedback for This product This page. View all page feedback. In this article. The following code snippet creates five buttons and add them to Toolbar. Add toolBarButton1.

Add toolBarButton2. Add toolBarButton3. Add toolBarButton4. Add toolBarButton5. Now, let's add a Toolbar button click event handler. This handler code will be executed when a button on the Toolbar is clicked. AddHandler mainToolBar. Add mainToolBar. The following code snippet sets these properties and also adds three images to the Toolbar control and later loops through the images and displays them on a Form.

Public Class Form1. Object , ByVal e As System. EventArgs Handles MyBase. End Sub. Private Sub CreateDnamicToolbar. Select Case mainToolBar. IndexOf e. Click on your ToolStrip to select it.

We'll keep this Name. But locate the Items Collection property:. To add a new button to your ToolStrip, click the Add button at the top. The button appears in the Members box ToolStripButton1 :. Notice that the new button has its own list of properties, just to the right.

To add an image to this new button, locate the Image property:. In the image above, we've selected "Project resource file", and then clicked the Import button.

We then navigated to some Bitmap images and imported the five that you can see in the screenshot above these are in the BITMAP folder that you download at the top of this tutorial. Click OK when you have imported some images.

You will be returned to the Item Collection Editor. Click OK on this, as well. The ToolStrip on your form will then look like this:. To add a new button to the toolstrip, click on Button from the drop down menu in the image above.

A default button is added called ToolStripButton2. The first button is called ToolStripButton1. To change the picture of the new button, locate the Image property in the properties area bottom right:. Click the button with the three dots in it to bring up the Select Resource dialogue box again.



0コメント

  • 1000 / 1000