winform动态生成新窗体并添加控件执行命令

主要代码

 Form nf = new Form();
            int _w = 400;
            int _h = 400;
            nf.Width = _w;
            nf.Height = _h;
            //添加textbox
            TextBox tb = new TextBox();
            tb.Name = "txt";
            tb.Multiline = true;
            tb.Top = 0;
            tb.Left = 0;
            tb.Width = _w;
            tb.Height = _h;
            tb.Text = "哈哈哈哈哈哈";
            nf.Controls.Add(tb); 
            nf.Show();
            for (int i = 0; i < 200; i++)
            {
                tb.AppendText(i+"哈哈 \r\n");
            }

使用环境:

winform程序等待数据加载过程,显示loading图片等等

winform程序执行批量插入,如示例一样,实时显示情况

转载于:https://www.cnblogs.com/ncellit/p/10790125.html

你可能感兴趣的:(winform动态生成新窗体并添加控件执行命令)