| |

VerySource

 Forgot password?
 Register
Search
View: 736|Reply: 2

How to create MDI child forms through threads

[Copy link]

4

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-17 21:40:01
| Show all posts |Read mode
private void btnCreate_Click (object sender, EventArgs e)
        {

            for (int i = 1; i <3; i ++)
            {
                _i = i;
                MethodInvoker mi = new MethodInvoker (this.InvokeFun);
                BeginInvoke (mi);
                
            }
        }

        private void InvokeFun ()
        {
            MdiChild formMdiChild = new MdiChild ();
            formMdiChild.LineNo = _i;
            formMdiChild.Text = _i.ToString ();
            formMdiChild.MdiParent = this;

            Thread t = new Thread (new ThreadStart (formMdiChild.Show));
            t.Start ();
        }
Reply

Use magic Report

0

Threads

27

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-23 23:27:01
| Show all posts
You set up MDI through delegation, not through threads.
Reply

Use magic Report

0

Threads

16

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-26 17:27:01
| Show all posts
Thread establishment should be Thread thread = new Thread (new ThreadStart (creat_MDIChild));

       public void creat_MDIChild ()
           {
                MethodInvoker mi = new MethodInvoker (this.InvokeFun);
                this.BeginInvoke (mi);
                
            }

        private void InvokeFun ()
        {
            MdiChild formMdiChild = new MdiChild ();
            formMdiChild.LineNo = _i;
            formMdiChild.Text = _i.ToString ();
            formMdiChild.MdiParent = this;
        }
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list