C#我怎样才能显示图像,而我的应用程序加载我的、应用程序、图像、加载

2023-09-08 08:36:01 作者:許你一世煙花

我已经和应用程序窗口形成.net和我的Form1上花费大量的时间后才会出现,因为它的活动Form1_Load的做了很多的操作。

i have and application windows form .net and my form1 takes a lot of time to appear because in it's event form1_Load does a lot of operation.

我的目标是显示一个图像,同时操作正在做的。

My goal is to show an image while the operation are being done.

    private void form1_Load(object sender, EventArgs e)
    {            
        methode1();
    }

虽然我methode1()的工作,我的形式犯规节目,我想在屏幕上显示的图像,而我的methode1()的工作,因为同时methode1()的工作,没有什么在屏幕上。

While my methode1() is working, my form doesnt show, i want to show an image on the screen while my methode1() is working because while methode1() is working, there is nothing on the screen.

推荐答案

在.NET中所有的视觉事情的形式完成。您可以通过创建一个小的形式,它包含一个图像模块1()之前,完成模块1()关闭后加载它做到这一点。正下方。

All the visual things in .net is done on form. You can do it by creating an small form which contains an image load it before module1() and after completing module1() close it. Just below..

private void form1_Load(object sender, EventArgs e)
{    
        Form f = new Form();
        f.Size = new Size(400, 10);
        f.FormBorderStyle = FormBorderStyle.None;
        f.MinimizeBox = false;
        f.MaximizeBox = false;
        Image im = Image.FromFile(path);
        PictureBox pb = new PictureBox();
        pb.Dock = DockStyle.Fill;
        pb.Image = im;
        pb.Location = new Point(5, 5);
        f.Controls.Add(pb);
        f.Show();        
        methode1();
        f.Close();
}