It's considered bad design to allow other classes to modify the internal controls of the form. The form should be responsible for all of it's components. You shouldn't ever make any of the internal controls public. It's also considered bad practice for a child form to have a reference to the parent form.
The appropriate way to approach this problem is through events. The child form, Form2
, should define a public event:
public event Action<int> TrackBarMoved;
Form2
can fire that event when the track bar is moved and pass, as the parameter, the position of the trackbar (if it makes sense to pass something else, such as the zoom level, or whatever else you want, that's fine too).
Form1
can the subscribe to that event when it creates From2
and change the zoom on the picture (internally, from within Form1
) based on what the trackbar position is.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…