Table of Contents

Property SelectedTool

Namespace
Alternet.FormDesigner.WinForms
Assembly
Alternet.FormDesigner.v9.dll

SelectedTool

Returns currently selected toolbox item.

[Browsable(false)]
public ToolboxItem SelectedTool { get; }

Property Value

ToolboxItem

Examples

Here is how to use a SelectedTool in the C# code:

using System.Text;
using System.Windows.Forms;

using Alternet.FormDesigner.WinForms;

public partial class Form1 : Form
{
    private toolboxControl = new ToolboxControl();

    private void Form1_Load(object sender, EventArgs e)
    {
        var formDesigner = new FormDesignerControl();
        formDesigner.AutoSaveToSource = false;
        formDesigner.Dock = System.Windows.Forms.DockStyle.Left;
        formDesigner.Parent = this;

        toolboxControl.Parent = this;
        toolboxControl.Dock = System.Windows.Forms.DockStyle.Fill;
        toolboxControl.FormDesignerControl = formDesigner;
        toolboxControl.PlaceItemAtDefaultLocation += ToolboxControl_PlaceItemAtDefaultLocation;
    }

    private void ToolboxControl_PlaceItemAtDefaultLocation(object sender, PlaceToolboxItemAtDefaultLocationEventArgs e)
    {
        MessageBox.Show("Place toolbox item at default location: " + toolboxControl.SelectedTool.DisplayName);
    }
}

Here is how to use a SelectedTool in the Visual Basic code:

Imports System
Imports System.Windows.Forms

Imports Alternet.FormDesigner.WinForms

Partial Public Class Form1
    Inherits Form

    Private toolboxControl = New ToolboxControl()

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim formDesigner = New FormDesignerControl()
        formDesigner.AutoSaveToSource = False
        formDesigner.Dock = Windows.Forms.DockStyle.Left
        formDesigner.Parent = Me

        toolboxControl.Parent = Me
        toolboxControl.Dock = Windows.Forms.DockStyle.Fill
        toolboxControl.FormDesignerControl = formDesigner
        AddHandler toolboxControl.PlaceItemAtDefaultLocation, AddressOf ToolboxControl_PlaceItemAtDefaultLocation
    End Sub

    Private Sub ToolboxControl_PlaceItemAtDefaultLocation(ByVal sender As Object, ByVal e As PlaceToolboxItemAtDefaultLocationEventArgs)
        MessageBox.Show("Place toolbox item at default location: " & toolboxControl.SelectedTool.DisplayName.ToString())
    End Sub
End Class

Remarks

The SelectedTool is a read-only property, it's changed when a user selects an item on the toolbox.