Try to set focus on the first control in the panel on Form_Load event:
panel1.Controls[0].Select();
質問
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?
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]);
}
解決
Try to set focus on the first control in the panel on Form_Load event:
panel1.Controls[0].Select();
他のヒント
You could use:
The ScrollControlIntoView
method:
panel.ScrollControlIntoView(panel.Controls[0]);
Panel's VerticalScroll
property:
panel.VerticalScroll.Value = 0;