Assam
Thanks for the reply but it didnt resolve my issue. Now i am not changing the location of the controls on the paint even rather Onlayout i am calling the following method. But now the problem is there's alot of flickering of child controls. Please see the code below may be i am doing something wrong. Also please note that i have to dynamically judge the position of the child controls
private void RenderPDFFields()
{
int scrollValue = vScroll.Value == 0 10 : vScroll.Value;
//Getting the current PDF page
int activePage = GetPageNumberAtPoint(new Point(Width / 2, scrollValue));
if (activePage > -1)
{
//Calculating the location of the page
Rectangle firstRect = _currentRectPages[activePage];
Point firstPageLoc = new Point(5);
Point secondPageLoc = new Point(5);
if (firstRect.Width < Width)
firstPageLoc = new Point(Width / 2 - firstRect.Width / 2);
Point p = new Point(firstPageLoc.X - hScroll.Value,
firstRect.Top - vScroll.Value);
_pnlPages[activePage].Location = p;
_pnlPages[activePage].Visible = true;
_pnlPages[activePage].Invalidate();
//Hiding previous page
if (activePage > 0)
_pnlPages[activePage - 1].Visible = false;
//If there's enough virtual space left then show the next page as well
if (activePage + 1 < _defaultRectPages.Length & _pnlPages[activePage].Location.Y < 0)
{
Rectangle secondRect = _currentRectPages[activePage + 1];
if (secondRect.Width < Width)
secondPageLoc = new Point(Width / 2 - secondRect.Width / 2);
_pnlPages[activePage + 1].Location = new Point(secondPageLoc.X - hScroll.Value,
(firstRect.Top - vScroll.Value) + firstRect.Height + 5);
_pnlPages[activePage + 1].Visible = true;
_pnlPages[activePage].Invalidate();
}
}
}