Code Snippet
Imports System.ComponentModel.Design
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim surface As New DesignSurface()
Dim host As IDesignerHost = TryCast(surface.GetService(GetType(IDesignerHost)), IDesignerHost)
Dim root As UserControl = TryCast(host.CreateComponent(GetType(UserControl)), UserControl)
root.BackColor = Color.AliceBlue
root.Width = Me.Width - 100
root.Height = Me.Height - 150
Dim flp As FlowLayoutPanel = TryCast(host.CreateComponent(GetType(FlowLayoutPanel)), FlowLayoutPanel)
flp.Text = "FlowLayoutPanel"
flp.Dock = DockStyle.Fill
root.Controls.Add(flp)
Dim c As Control = TryCast(surface.View, Control)
c.BackColor = Color.White
c.Width = Me.Width - 30
c.Height = Me.Height - 50
c.Location = New Point(15, 25)
c.Parent = Me
Dim tb As TextBox = TryCast(host.CreateComponent(GetType(TextBox)), TextBox)
tb.Size = New Size(50, 100)
tb.Text = "TextBox"
AddHandler tb.MouseDown, Me.mMove
flp.Controls.Add(tb)
End Sub
Public Sub mMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Right Then
Msgbox ("Hi")
end if
End Sub