In my application, I have a LineShape control and a custom control (essentially a PictureBox with a label).
I want LineShape to change one of its point coordinates, according to the location of the custom control.
I had the idea of โโlinking to a LineShape point inside a custom control and adding a location change event handler that changes the coordinates of the anchor points.
However, an inline point is a structure that is a type of value, so this will not work. Does anyone have an idea how to link to a structure or maybe someone knows a workaround for my problem?
I tried the solution regarding using a NULL type, but it still does not work. Here I define a field in my custom control (DeviceControl):
private Point? mConnectionPoint;
And the implementation of the location change event handler:
private void DeviceControl_LocationChanged(object sender, EventArgs e) { if (mConnectionPoint != null) { DeviceControl control = (DeviceControl)sender; Point centerPoint= new Point(); centerPoint.X = control.Location.X + control.Width / 2; centerPoint.Y = control.Location.Y + control.Height / 2; mConnectionPoint = centerPoint; } }
reference c # struct
Maksymilian chwaลek
source share