How to get mouseclick from vs designer

  • Thread starter Thread starter mikrogen
  • Start date Start date
M

mikrogen

How can I determine if a user has clicked on the control in the designer? I would like to change my usercontrol appearance after clicking buttons in that usercontrol.

How can I react on dropping other controls onto my usercontrol? Is there any tutorial for that?

Thank you very much,

mikrogen
 
mikrogen said:
How can I determine if a user has clicked on the control in the designer? I would like to change my usercontrol appearance after clicking buttons in that usercontrol.

How can I react on dropping other controls onto my usercontrol? Is there any tutorial for that?

Hi mikrogen,

the best way is to derive your own class from
System.Windows.Forms.Design.ControlDesigner (add a reference to
System.Design.dll)

public class MyControlDesigner : System.Windows.Forms.Design.ControlDesigner
{
public override void OnPaintAdornments(PaintEventArgs e)
{
//Design time painting here
//Draw a rectangle around the control
}
}

and add this class to your custom control using the
System.ComponentModel.DesignerAttribute

[System.ComponentModel.Designer(typeof(MyNameSpace.MyControlDesigner))]
public class MyControl : Control
{
public override void OnPaint(object sender, PaintEventArgs e)
{
//Normal painting here
}
}

Tutorials are here:

http://www.divil.co.uk/net/articles/designers/introduction.asp
http://www.howtodothings.com/showarticle.asp?article=706

Documentation (with examples):
http://msdn.microsoft.com/library/e...ndowsformsdesigncontroldesignerclasstopic.asp

More info:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconEnhancingDesign-TimeSupport.asp

Cheers

Arne Janning
 
Back
Top