ok, the problem appears when the AutoScroll
property of panel is set to true
and the scroll bar is not at its initial position:0. The panel is positionning the controls at ypos + vertical position of scroll bar
!!
Either set AutoScroll = false;
before adding MovieItem
then true;
after, but this will reset the scroll bar position
or, substract the scroll bar position from ypos
when setting the location.
Both fix the problem but the 2nd is better (no scroll bar reset):
public void X()
{
int vscrollPos = panel1.VerticalScroll.Value;
MovieItem NewMovie = new MovieItem();
NewMovie.SearchMovie(txtSearch.Text);
NewMovie.Location = new Point(0, ypos - vscrollPos);
ypos += 196;
panel1.Controls.Add(NewMovie);
}