怎样使窗体一出来就是隐藏的? 我在构造里写this.Hide();没有作用我要是真正的隐藏,而不是最小化不显示在任务栏中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在窗体的paint事件中加入this.visible=false static void Main() { login newForm=new login(); newForm.ShowDialog(); Application.Run(new Form1()); }这样Form1出来就是隐藏的!login是显示的! 楼上的办法不错.但是如果说你只是想运行一些不需要Windows窗口显示的程序的话,完全可以"生成控制台应用程序"或"Windows服务"类的项目.这样的程序体积更小运行更快. 不知你为何要将其设置成“隐藏”,如果只是想暂时隐藏窗体,在 From_Load 中写“this.visible=false”。如果想永远隐藏,建议做成“Windows Service” From_Load 中写“this.visible=false”不好用 \\下面是按你的问题刚写的代码,using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using Microsoft.Win32;using System.Data.SqlClient;namespace Zhzuo.WindowsTest{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.Button button1; private System.ComponentModel.IContainer components; public Form1() { InitializeComponent(); } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // notifyIcon1 // this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); this.notifyIcon1.Text = "notifyIcon1"; this.notifyIcon1.Visible = true; this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); // // button1 // this.button1.Location = new System.Drawing.Point(344, 200); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "隐藏"; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(464, 289); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void ShowHideWindow(bool showWindow) { if(showWindow == true)//显示 { if(this.ShowInTaskbar==false) { this.ShowInTaskbar = true; this.Visible = true; //this.Show(); } if(this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } this.Activate(); } else//隐藏 { if(this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } if(this.ShowInTaskbar == true) { this.ShowInTaskbar = false; this.Visible = false; //this.Hide(); } } } private void Form1_Load(object sender, System.EventArgs e) { ShowHideWindow(false); } private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) { //显示 ShowHideWindow(true); } private void button1_Click(object sender, System.EventArgs e) { //隐藏 ShowHideWindow(false); } }} webbrowser获取窗体内的图片 请教泛型基础知识 急!刚接手一个.net项目 怎样把数据fill在datatable中? 有没有人知道怎样让窗体初始化的时候,让窗体出现在屏幕右下方 关于在C#中按F1帮助的问题 richeditbox中的超链接 我有一个自定义类,如何定义事件:当退出类时,做一些操作? 一个大家都解决不了的小问题。 这个框很难输入文字,没顶尖高手不行,真是不假!~~ 高分求水晶报表中怎样显示特定的行(在线等,急需!!) 关于制作安装程序的问题
{
login newForm=new login();
newForm.ShowDialog();
Application.Run(new Form1());
}
这样Form1出来就是隐藏的!login是显示的!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Win32;
using System.Data.SqlClient;namespace Zhzuo.WindowsTest
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.Button button1;
private System.ComponentModel.IContainer components; public Form1()
{
InitializeComponent();
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// notifyIcon1
//
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
//
// button1
//
this.button1.Location = new System.Drawing.Point(344, 200);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "隐藏";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(464, 289);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void ShowHideWindow(bool showWindow)
{
if(showWindow == true)//显示
{
if(this.ShowInTaskbar==false)
{
this.ShowInTaskbar = true;
this.Visible = true;
//this.Show();
}
if(this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
this.Activate();
}
else//隐藏
{
if(this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
if(this.ShowInTaskbar == true)
{
this.ShowInTaskbar = false;
this.Visible = false;
//this.Hide();
}
}
} private void Form1_Load(object sender, System.EventArgs e)
{
ShowHideWindow(false);
} private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
//显示
ShowHideWindow(true);
} private void button1_Click(object sender, System.EventArgs e)
{
//隐藏
ShowHideWindow(false);
}
}
}