-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Setting ShowInTaskbar to false causes the form to close automatically (Abnormal exit).
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form
Test Code:
.NET 6.0 (Version: 6.0.1)(This problem also appears in .net framework 4.8)
Win10 system (21H2).
using System;
using System.Windows.Forms;
namespace FormShowInTaskbarTest
{
internal static class Program
{
private static Form form1;
private static Form form2;
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
form1 = new Form()
{
Width = 800,
Height = 600,
StartPosition = FormStartPosition.CenterScreen,
};
var button1 = new Button()
{
Text = "Click here to open new Form.",
Width = 200,
Height = 100,
};
button1.Click += Button1_Click;
form1.Controls.Add(button1);
Application.Run(form1);
}
private static void Button1_Click(object sender, EventArgs e)
{
form2 = new Form()
{
Width = 600,
Height = 400,
StartPosition = FormStartPosition.CenterScreen,
};
var button2 = new Button()
{
Text = "Click here to test ShowInTaskbar.",
Width = 200,
Height = 100,
};
button2.Click += Button2_Click;
form2.Controls.Add(button2);
form2.ShowDialog(form1);
}
private static void Button2_Click(object sender, EventArgs e)
{
form2.ShowInTaskbar = false;
}
}
}
Steps to reproduce:
- Run the appliction.
- Click the first button, the application will open a new Form.
- Click the first button in new form.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels