Is this a standard WinForm app ?
I can't observe the behavior you describe in a WinForms app with a Button and an OpenFileDialog:
namespace testbuttonload
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Shown(object sender, EventArgs e)
{
button1.PerformClick();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
Console.WriteLine(result);
}
}
}
Something else in your code is causing the Button to be clicked before the Shown event ... check:
1) your Form Load handler is not calling PerformClick
2) Form click handler, or other events, are not calling PerformClick