请教一段程序

来源:百度知道 编辑:UC知道 时间:2024/06/08 05:43:35
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication25
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
//设置计时器开启
timer1.Enabled = true;
timer1.Interval = 50; // 50毫秒
progressBar1.Maximum = 100;
}

private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < progressBar1.Maximum)
{
progressBar1.Value++; // 状态条增加
}
else
{
//设置计时器关闭
ti

如果你Program.cs

Application.Run(new Form1());

主进程在Form1 那么Form1.Close()会导致整个程序关闭

百变精灵之王 的方法是把主程设在Form2,这样的话程序运行会先运行Form2//会强制先SHOW出form2的

这样的话你要在form2 load时 this.Hide();//隐藏自己~然后Form1.show//实例化就不说了~

<script>
window.open("main.htm","_blank");
window.opener=null
window.close();
</script>

因为主窗体关闭以后程序就会关闭所以当然不行。
在Program.cs中添加
Application.Run(new Form2());
就行了。

恩,不错,挺牛的!!!