private void button1_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
this.Hide(); // 隐藏当前窗体
form1.ShowDialog(); // 定向打开窗体 Form1 ,当为 form1.Show() 时,则打开后立即关闭
this.Close(); // 关闭当前窗体
}
2、将当前窗体最小话
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsForms
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void FormMain_Load(object sender, EventArgs e)
{
//窗体最小化显示
this.WindowState = FormWindowState.Minimized;
//不显示在任务栏中
this.ShowInTaskbar = false;
}
/// <summary>
/// 让程序不显示在alt+Tab视图窗体中
/// </summary>
protected override CreateParams CreateParams
{
get
{
const int WS_EX_APPWINDOW = 0x40000;
const int WS_EX_TOOLWINDOW = 0x80;
CreateParams cp = base.CreateParams;
cp.ExStyle &= (~WS_EX_APPWINDOW); // 不显示在TaskBar
cp.ExStyle |= WS_EX_TOOLWINDOW; // 不显示在Alt+Tab
return cp;
}
}
}
}
参考自:
1、http://bbs.csdn.net/topics/392055218?page=1
2、https://blog.csdn.net/tingzgq/article/details/7622458?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.pc_relevant_is_cache&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.pc_relevant_is_cache
平时多记记,到用时才能看看,记录你的进步,分享你的成果