logo
Учебник_ПОА

To add a set of standard toolbar button

  1. On the File menu, click New Project.

The New Project dialog box appears.

  1. Click Windows Forms Application and then click OK.

  2. Drag a ToolStrip control from the Toolbox to the form.

toolStrip1 appears in the component tray, and a toolbar is added to the top of the form.

  1. Add a TextBox control to the form and leave the default name of textBox1.

  2. Click the TextBox control, and then change the following properties in the Properties window:

    Property

    Value

    Size

    260, 20

    Text

    This is a simple test

  3. Click the ToolStrip control, click the smart task arrow at the upper-right corner of the control, and then click Insert Standard Items.

Seven standard buttons (New, Open, Save, Print, Cut, Copy, Paste, and Help) become visible on the toolbar.

  1. Double-click the CutToolStripButton control to add the default Click event handler, and add the following code. This code cuts the selected text in TextBox1 and copies it to the Clipboard.

    this.textBox1.Cut();

  2. Press F5 to run the code.

  3. When the form appears, select a word in the text box, and then click the Cut button (that has a scissor icon).

  4. Verify that the selected text has been removed from the text box.

Note:

You must add code to the Click event handlers for the remaining buttons on the toolbar to get additional functionality.