C# 如何在显示任务栏的情况下运行winform?

C# 如何在显示任务栏的情况下运行winform?,c#,winforms,C#,Winforms,我有一个C#2017项目,主窗体是无边框(在属性中设置)。它总是以最大化开始,起始位置是windowsdefaultlocation/manual(我尝试过)。我尝试了很多代码,但它仍然运行并隐藏任务栏 我想在无边框、最大化/全屏模式下运行窗体,窗体不会隐藏windows 10的任务栏 尝试了以下链接: private void Form1\u加载(对象发送方,事件参数e) { this.Height=Screen.PrimaryScreen.WorkingArea.Height; thi

我有一个C#2017项目,主窗体是无边框(在属性中设置)。它总是以最大化开始,起始位置是windowsdefaultlocation/manual(我尝试过)。我尝试了很多代码,但它仍然运行并隐藏任务栏

我想在无边框、最大化/全屏模式下运行窗体,窗体不会隐藏windows 10的任务栏

尝试了以下链接:

private void Form1\u加载(对象发送方,事件参数e)
{
this.Height=Screen.PrimaryScreen.WorkingArea.Height;
this.Width=Screen.PrimaryScreen.WorkingArea.Width;
this.Location=Screen.PrimaryScreen.WorkingArea.Location;
//Screen currentScreen=Screen.FromHandle(this.Handle);
//this.Size=new System.Drawing.Size(currentScreen.Bounds.Width,currentScreen.Bounds.Height);
}
这对我没有任何帮助。如果你有什么解决办法,请帮助我


非常感谢大家。

当您的
边框样式
为“无”时,将窗体
窗口状态设置为最大化将始终位于任务栏上。这是“全屏”应用程序的典型行为

然而,你在正确的轨道上。如果您想在不使用任务栏的情况下获得半全屏体验,则必须手动设置表单的位置和大小

这里很重要的一点是,您不仅可以手动设置这些值,还可以从操作系统本身获取控制权,因为它总是试图通过一些规则集定位表单

private void Form1_Load(object sender, EventArgs e)
{
  //Hiding the Border to simulate a fullscreen-experience
  this.FormBorderStyle = FormBorderStyle.None;
  //Telling the operating system that we want to set the start position manually
  this.StartPosition = FormStartPosition.Manual;

  //Actually setting our Width, Height, and Location
  this.Height = Screen.PrimaryScreen.WorkingArea.Height;
  this.Width = Screen.PrimaryScreen.WorkingArea.Width;
  this.Location = Screen.PrimaryScreen.WorkingArea.Location;
}

只是一个小小的侧节点:您可能想考虑有多个屏幕的人以及应用程序应该出现在哪个屏幕上(可能让用户通过一些设置等来决定)。

也许这一个与我需要的东西非常相似:

this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size ;