0

When I put control on my custom DesignSurface a 'resize border' is drawn. It's standard border well known from VS Designer - dotted with eight 'anchors' to resize control. Unlucky when I change control's size or location programmatically this border does not apply this changes itself. I have to unselect and then select this control by mouse to force redraw.

My question is: How can I access this border from code and force redraw programmatically?

Thanks in advance!

zgorawski
  • 2,597
  • 4
  • 30
  • 43

1 Answers1

0

for example:changed control's location

don't like this:

Control control = new Control();
control.Location=new Point(10,10);

try this:

Control control = new Control();
PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(control)["Location"];
if (propertyDescriptor != null)
{
  Point point = (Point)propertyDescriptor.GetValue(control);
  point.Offset(5, 5);
  propertyDescriptor.SetValue(control, point);
}

the method "SetValue" of the PropertyDescriptor can fire the "ComponentChanged" event that notify the designer redraw.

matrix
  • 64
  • 6