I am trying to create a custom form designer, I am using the following code which works fine.
DesignSurface surface = new DesignSurface(typeof(UserControl));
ServiceContainer sc = new ServiceContainer(surface);
Control c = surface.View as Control;
c.Click += new EventHandler(c_Click);
if (c != null)
{
c.Dock = DockStyle.Fill;
this.tabPage1.Controls.Add(c);
}
Control designer = surface.ComponentContainer.Components[0] as Control;
designer.Dock = DockStyle.Fill;
designer.BackColor = System.Drawing.Color.Transparent;
IDesignerHost host = (IDesignerHost)sc.GetService(typeof(IDesignerHost));
The problem comes I am trying to create verbs which I assume are context menu options. I have a custom control that inherits the textbox, which even though I add verbs does not work in runtime.
IDesigner oIDesigner = host.GetDesigner(oControl);
oIDesigner.Verbs.Add(new DesignerVerb("Click", new EventHandler(OnClick)));
The OnClick never fires on click nor does it show in a context menu. I can see the control and move it around.
Thanks