简体   繁体   中英

C# : Prevent child modal form from creating instance on taskbar

I have a parent form. When i click a button, a modal child form appeare within the form and is located at the center of the parent form :

儿童形式

but the problem is in the taskbar, the application have 2 instances :

任务栏

How do i prevent this second instance or Hide it from the taskbar ? Thanks !

When you instantiate the second form, set the ShowInTaskbar property to False to prevent it from showing up in the Windows task bar.

You don't show the code where you instantiate and display the form, but something like this should work:

var secondForm = new Form2
                     {
                         ShowInTaskbar = false,
                         StartPosition = FormStartPosition.CenterParent
                     };

secondForm.ShowDialog();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM