What my code should do: Inside a panel1, I put many linklabels , and I want when the program starts, to jump to last linklabel used/clicked. For that i use
panel1.AutoScrollPosition = new Point(0, 2000);
I tried 3 events where i put my code to execute, and
only in the button event it executes. In the Form1() and Form1_Load event my code is not executing at all, and i tried diferent debuging techniques i know under my sleeves.
What I have tried:
public Form1()
{
InitializeComponent();
for (int i = 0; i < line.Length; i++)
{
LinkLabel linklabel = new LinkLabel();
linklabel.Location = new Point(0, 22 * (i + 1));
panel1.Controls.Add(linklabel);
}
panel1.AutoScrollPosition = new Point(0, 2000);
Refresh();
button1.PerformClick();
Application.DoEvents();
}
private void Form1_Load(object sender, EventArgs e)
{
panel1.AutoScrollPosition = new Point(0, 2000);
Refresh();
button1.PerformClick();
Application.DoEvents();
}
private void button1_Click(object sender, EventArgs e)
{
panel1.AutoScrollPosition = new Point(0, 2000);
}