I am creating a windows application using C#.Net. I am showing a form when starting an applicat开发者_如何学Pythonion using below code :
Form myForm = new MyForm();
Application.Run(myForm);
Application is not appearing in taskbar, but I know its running since I can navigate to the application window using Alt-TAB.
If I use myForm.ShowDialog()
, application is visible in taskbar.
What am I missing here?
UPDATE: ShowInTaskbar
property is set to true for the form.
UPDATE2: FormBorderStyle
is set to None
Toggle ShowInTaskbar
in your form load
event with these two lines:
This.ShowInTaskbar = False
This.ShowInTaskbar = True
It worked for me.
Add Activate() in Form_Shown event.
With .NET Framework 4.6.1, toggling:
this.ShowInTaskBar = false;
this.ShowInTaskBar = true;
causes FormClosing
event being fired.
Calling this.Activate()
in Shown
event works properly.
In my case it was nonmodal form, called to be shown with ShowDialog()
, but the request to create and show the form was sent from pipe. When executed by user's click on main form, everything was ok, form was shown and appeared on the taskbar.
You may not set an empty string as windows title during Form load. This is what happened to me today (my window title is retrieved from a file that was missing, and so the window disappeared from the taskbar).
精彩评论