Property FormDesignerControl
- Namespace
- Alternet.FormDesigner.WinForms
- Assembly
- Alternet.FormDesigner.v9.dll
FormDesignerControl
Provides an interface to support all standard form editing operations with controls.
public IFormDesignerControl FormDesignerControl { get; set; }
Property Value
Examples
Here is how to use a FormDesignerControl in the C# code:
using Alternet.FormDesigner.WinForms;
public partial class Form1 : Form
{
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;
var toolboxControl = new ToolboxControl();
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)
{
if ((e.Item != null) && string.IsNullOrEmpty(e.Item.DisplayName))
{
System.Windows.Forms.MessageBox.Show(string.Format("Item: {0} added", e.Item.DisplayName));
}
}
}
Here is how to use a FormDesignerControl in the Visual Basic code:
Imports System
Imports Alternet.FormDesigner.WinForms
Partial Public Class Form1
Inherits Form
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
Dim toolboxControl = New ToolboxControl()
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)
If e.Item IsNot Nothing AndAlso String.IsNullOrEmpty(e.Item.DisplayName) Then
Windows.Forms.MessageBox.Show(String.Format("Item: {0} added", e.Item.DisplayName))
End If
End Sub
End Class
Remarks
You can associate the Form designer with the ToolboxControl object by setting FormDesignerControl property. This allows users to place components onto the designer's surface, by dragging them from the toolbox.