// -------------------------------------------------------------------------------------
        /// <summary>
        /// Add QuestionControl as child control to the TemplateControl.
        /// Controls appeared by layout specified by IQestion.QuestionLayout property
        /// </summary>
        /// <param name="question">Question to add</param>
        /// <returns>Added question control</returns>
        // -------------------------------------------------------------------------------------
        private IQuestionControl CreateQuestionControl(IQuestion question)
        {
            Panel itemPanel = new Panel();
              m_QuestionPanel.Controls.Add(itemPanel);

              ToolTip toolTip = new ToolTip();
              toolTip.AutoPopDelay = 5000;
              toolTip.InitialDelay = 1000;
              toolTip.ReshowDelay = 500;
              toolTip.ShowAlways = true;
              toolTip.SetToolTip(itemPanel, question.QuestionDescription);

              // --- Add question text
              QuestionLabelControl questionLabel = new QuestionLabelControl();
              questionLabel.Text = question.Question;
              questionLabel.AutoSize = true;
              itemPanel.Controls.Add(questionLabel);
              toolTip.SetToolTip(questionLabel, question.QuestionDescription);

              // --- Create control by Layout
              QuestionLayout layout = question.QuestionLayout;
              IQuestionControl controlToAdd = null;
              switch (layout)
              {
            case QuestionLayout.Check:
              controlToAdd = new QuestionCheckControl();
              break;
            case QuestionLayout.Combo:
              controlToAdd = new QuestionListControl();
              break;
            case QuestionLayout.Radio:
              controlToAdd = new QuestionRadioControl();
              break;
            case QuestionLayout.Text:
              controlToAdd = new QuestionTextControl();
              break;
            case QuestionLayout.MultiLineText:
              controlToAdd = new QuestionTextControl();
              break;
              }
              ((Control) controlToAdd).Name = "IQuestionControl" + question.QuestionInternalID;
              ((Control) controlToAdd).Tag = questionLabel;
              controlToAdd.IQuestion = (IQuestion) question;
              controlToAdd.State = State;
              itemPanel.Controls.Add((Control) controlToAdd);
              controlToAdd.DisplayControl();
              return controlToAdd;
        }
        private void CreatePager()
        {
            // --- Create page index cell
              m_PageIndexLabel = new QuestionLabelControl();
              m_PagerPanel.Controls.Add(m_PageIndexLabel);

              // --- Create page buttons
              cmdFirst = new LinkLabel();
              cmdFirst.Text = "<<";
              cmdFirst.Name = "btnFirst";
              cmdFirst.FlatStyle = FlatStyle.Flat;
              cmdFirst.Cursor = Cursors.Hand;
              cmdFirst.Click += new EventHandler(FirstPage);
              m_PagerPanel.Controls.Add(cmdFirst);

              cmdPrev = new LinkLabel();
              cmdPrev.Text = "<Elõzõ";
              cmdPrev.Name = "btnPrev";
              cmdPrev.FlatStyle = FlatStyle.Flat;
              cmdPrev.Cursor = Cursors.Hand;
              cmdPrev.Click += new EventHandler(PrevPage);
              m_PagerPanel.Controls.Add(cmdPrev);

              cmdNext = new LinkLabel();
              cmdNext.Text = "Következõ>";
              cmdNext.Name = "btnNext";
              cmdNext.FlatStyle = FlatStyle.Flat;
              cmdNext.Cursor = Cursors.Hand;
              cmdNext.Click += new EventHandler(NextPage);
              m_PagerPanel.Controls.Add(cmdNext);

              cmdLast = new LinkLabel();
              cmdLast.Text = ">>";
              cmdLast.Name = "btnLast";
              cmdLast.FlatStyle = FlatStyle.Flat;
              cmdLast.Cursor = Cursors.Hand;
              cmdLast.Click += new EventHandler(LastPage);
              m_PagerPanel.Controls.Add(cmdLast);
        }
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Create panels wich arranges all child control
        /// </summary>
        /// <param name="pageCount">Number of pages (rows) in the template (sum of all pages)</param>		
        // -------------------------------------------------------------------------------------
        private void CreatePanels()
        {
            if (m_PanelsCreated)
            return;

              // --- Create header panel
              m_HeaderPanel = new Panel();
              m_HeaderPanel.BorderStyle = BorderStyle.Fixed3D;
              Controls.Add(m_HeaderPanel);
              m_TemplateNameLabel = new QuestionLabelControl();
              m_TemplateNameLabel.TextAlign = ContentAlignment.TopCenter;
              m_HeaderPanel.Controls.Add(m_TemplateNameLabel);

              // --- Create pagename QuestionLabelControl
              m_PageNameLabel = new QuestionLabelControl();
              m_HeaderPanel.Controls.Add(m_PageNameLabel);

              // --- Create validation
              m_ValidationPanel = new Panel();
              m_ValidationPanel.BorderStyle = BorderStyle.Fixed3D;
              m_ValidationPanel.AutoScroll = true;
              Controls.Add(m_ValidationPanel);
              m_ValidationLabel = new QuestionLabelControl();
              m_ValidationLabel.Font = new Font("Arial", 8);
              m_ValidationLabel.ForeColor = Color.Red;
              m_ValidationPanel.Controls.Add(m_ValidationLabel);

              // --- Create QuestionPanel
              m_QuestionPanel = new Panel();
              m_QuestionPanel.AutoScroll = true;
              m_QuestionPanel.BorderStyle = BorderStyle.Fixed3D;
              Controls.Add(m_QuestionPanel);

              // --- Create PagerPanel
              m_PagerPanel = new Panel();
              m_PagerPanel.BorderStyle = BorderStyle.Fixed3D;
              Controls.Add(m_PagerPanel);

              CreatePager();

              m_PanelsCreated = true;
        }
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Display question with a given state
        /// </summary>
        /// <param name="state">State to display</param>
        // -------------------------------------------------------------------------------------
        public void DisplayControl(ControlState state)
        {
            if (m_Question == null)
            return;

              Controls.Clear();

              //this.ToolTip = m_Question.QuestionDescription;

              // --- Add radio buttons to cells
              if (QuestionItemList == null)
              {
            Label literal = new Label();

            literal.Text = "Nincs megadott kérdés.";
            Controls.Add(literal);
            return;
              }

              if (m_ControlState != ControlState.ReadOnly)
              {
            int controlPos = 0;
            ArrayList items = QuestionItemList.SortBy();
            for (int i = 0; i < items.Count; i++)
            {
              QuestionListItem listItem = (QuestionListItem) items[i];

              CheckBox chk = new CheckBox();
              chk.Top = controlPos;
              chk.Left = 24;
              chk.Height = Convert.ToInt32(chk.Font.GetHeight()*(m_Question.QuestionItemList.ControlRows==0?1:m_Question.QuestionItemList.ControlRows)) + 4;
              chk.Width = m_Question.QuestionItemList.Width;
              chk.Name = i.ToString();
              chk.Text = listItem.ItemName;
              // Set up the ToolTip text for the Button and Checkbox.
              toolTip1.SetToolTip(chk, chk.Text);
              chk.Checked = listItem.Selected;
              Controls.Add(chk);
              controlPos += chk.Height + 4;
            }
            Height = controlPos + 8;

            // --- Validation
            m_ValidationLabel.Font = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
            m_ValidationLabel.ForeColor = Color.Red;
            Controls.Add(m_ValidationLabel);
            DisplayValidationError();
              }
              else
              {
            QuestionLabelControl label = new QuestionLabelControl();
            label.Top = 0;
            label.Left = 0;
            label.Text = m_Question.Answer.Replace("|", ", ");
            label.AutoSize = false;
            label.Width = Width - label.Left;
            Controls.Add(label);
            Height = label.Top + label.Height;
              }
              LoadAnswer();
        }