Exemple #1
0
        /// <summary>
        /// 添加文本框到标签页的方法
        /// </summary>
        public static void addMainTextToPage(TabPage page, TextBox t)
        {
            string timeStr = DateTime.Now.ToUniversalTime().Ticks.ToString();

            // 判断要添加的标签是否为null,为null则新建一个标签并添加
            // t.Location = new Point(0, 2);
            t.Size = new Size(page.ClientSize.Width - t.Location.X
                              , page.ClientSize.Height - t.Location.Y);
            if (page == null)
            {
                MainTabContent.addControlsToPage(t, true, true);
            }
            else
            {
                page.Controls.Add(t);
                t.BringToFront();
            }
            ControlsUtilsMet.timersMet(200, (object sender, ElapsedEventArgs e) => {
                if (t != null)
                {
                    if (t.InvokeRequired)
                    {
                        t.Invoke(new EventHandler(delegate {
                            if (t.FindForm() != null)
                            {
                                t.FindForm().ActiveControl = t;
                                ((System.Timers.Timer)sender).Dispose();
                            }
                        }));
                    }
                }
            });
        }