Question

I have program that is some kind of testing. I keep questions in panel, but when I run my program, it show the middle of panel. How to make it show the beginning of the panel? enter image description here

private void Form1_Load(object sender, EventArgs e)
        {

            for (int i = 0; i < 10; i++)
            {
                Dictionary<string, bool> answers = new Dictionary<string,bool>();
                for (int j = 0; j < 4; j++)
                {
                    string ans = "Відповідь " + (j+1);
                    bool flag = false;
                    if( i > 5)
                    {
                        if( j == 0 || j == 2)
                        {
                            flag = true;
                        }
                    }else
                        if (j == 0)
                        {
                            flag = true;
                        }
                    answers.Add(ans, flag);
                }
                string q_text = "Питання № " + (i+1);
                this.AddQuestion(q_text, answers);
            }
            panel1.ScrollControlIntoView(panel1.Controls[0]);
        }
Was it helpful?

Solution

Try to set focus on the first control in the panel on Form_Load event:

panel1.Controls[0].Select();

OTHER TIPS

You could use:

  1. The ScrollControlIntoView method:

    panel.ScrollControlIntoView(panel.Controls[0]);
    
  2. Panel's VerticalScroll property:

    panel.VerticalScroll.Value = 0;
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top