The Problem: There is no way to start a program minimized in the system tray
The Cause: The correct event is the Shown event, which is not intuitive (to me anyway).
The Solution: Just add in the following code:
private void MyForm_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == WindowState)
{
Hide();
}
}private void MyForm_Load(object sender, EventArgs e)
{
this.Hide();
}
private void MyForm_Shown(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
Hide();
}
and you’re done! You can then the start the program and it will automatically minimnize itself to the tray.
This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog