我刚刚开始学习C#,有些问题请教大家了!!
1:启动时不显示窗体
自己找了些资料查看,有人说:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
this.Hide();
}
但是加入这句,实际上窗体会闪一下,通过Application.Run(new form1);实例化一个新的对象,如何才能有效的不显示窗体??
2:启动时同时显示多个窗体
private static void Main()
{
Application.Run(new form1());
Application.Run(new form1());
Application.Run(new form1());
}
我像上面那样写,发现只有一个窗体显示,而且只有关闭了一个窗体,才会产生下一个窗体,我想请问: 如何在一开始就能够让多个窗体同时被实例化,然后显示出来??
1:启动时不显示窗体
自己找了些资料查看,有人说:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
this.Hide();
}
但是加入这句,实际上窗体会闪一下,通过Application.Run(new form1);实例化一个新的对象,如何才能有效的不显示窗体??
2:启动时同时显示多个窗体
private static void Main()
{
Application.Run(new form1());
Application.Run(new form1());
Application.Run(new form1());
}
我像上面那样写,发现只有一个窗体显示,而且只有关闭了一个窗体,才会产生下一个窗体,我想请问: 如何在一开始就能够让多个窗体同时被实例化,然后显示出来??
解决方案 »
- 筒子,如何实现这种方式的密码保存?
- PowerPoint could not open the file
- C#读取文件夹内的不同文件后缀名得瑟文件名字问题,在线等!还请高手帮忙解决,马上给分,急急急急..................................
- MessageBox 多语言显示问题
- 水晶报表打印问题~无论怎么样都不能横向打印
- testbox文本框对应显示dataGrid1的内容
- 如果得到DataGrid的排序后当前选择行对应的DataRow
- 那位朋友帮我看一下,下面代码那里出问题
- C#中哪里有WebBrowser控件吗?
- C#删除xml节点,很急,请高手指教啊
- 如何在tabcontrol的tabpage上放工具栏?
- 关于TAG属性的使用
private static void Main()
{
Application.Run(new form());
}
//在类中加入以下函数,会先闪一下,然后才消失
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
this.Hide();
}
我像请问启动程序时如何才能有效的不显示窗体??,而是在之后由其余的事件触发??
2:启动时同时显示多个窗体,我写的main函数如下.
private static void Main()
{
Application.Run(new form1());
Application.Run(new form1());
Application.Run(new form1());
}
像上面那样写,始终只有一个窗体显示,而且只有关闭了一个窗体,才会产生下一个窗体.
我想请问: 如何在程序一开始就能够让多个窗体同时被实例化,比如实例化3个窗体X1,X2,X3,然后让它们同时显示出来,而不是只有一个关闭后才能显示下一个?? LS的Big Brother,这下应该说清楚了吧??求助!!
这个不知所谓
2:启动时同时显示多个窗体
Application.Run(new form1()); 这个方法一直到用户关闭窗口时才返回,继续执行下边的代码
2:我知道Application.Run的这个特性,所以我想请问还有没有其它的方法使得不必关闭前面的窗体,而让后面的窗体也能紧随着实例化并显示处理.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;namespace WindowsFormsApplication1 {
static class Program {
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault( false );
Form1 frm1 = new Form1();
frm1.Show(); Form1 frm2 = new Form1();
frm2.Show();
Application.Run( );
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;namespace WindowsFormsApplication1 {
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault( false ); Form1 frm2 = new Form1();
frm2.Load += new EventHandler( frm2_Load );
Application.Run( frm2 );
} static void frm2_Load( object sender, EventArgs e ) {
Form1 frm2 = sender as Form1;
if( frm2 != null ) {
frm2.Show();
}
}
} public class Form1 : Form {
public Form1() {
InitializeComponent();
System.Threading.Thread.Sleep( 1000 * 3 );
} private System.ComponentModel.IContainer components = null;
protected override void Dispose( bool disposing ) {
if( disposing && ( components != null ) ) {
components.Dispose();
}
base.Dispose( disposing );
}
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
}
}
}