关键属性 AutoScrollMinSize
private int minWidth = 800; private int minHeight = 600; List
Sunny.UI.Common.ShowWaitForm(); try { //检测当前FORM是否存在。 Form form = listForm.SingleOrDefault(a => a.Name == name); if (form != null && form.IsDisposed) { listForm.Remove(form); form = null; } if (form == null) { //新建page TabPage tabPage = new TabPage(); tabPage.Name = name + "\_tab"; tabPage.Tag = name; tabPage.TabIndex = listForm.Count; tabPage.Text = title; tabPage.UseVisualStyleBackColor = true; tabPage.AutoScroll = true; tabPage.AutoScrollMinSize = new Size(w, h); mianTabContorl.Controls.Add(tabPage); //新建panel,网上听说要添加pannel。可是没用 //UIPanel uIPanel = new UIPanel(); //uIPanel.Font = new System.Drawing.Font("微软雅黑", 9F); //uIPanel.Text = ""; //uIPanel.Dock = DockStyle.Fill; //uIPanel.AutoScroll = true; //uIPanel.MinimumSize = new Size(minWidth, minHeight); //tabPage.Controls.Add(uIPanel); //根据命名空间.类名动态创建Form对象 form = (Form)assembly.CreateInstance("TestProduct." + name); form.MdiParent = this; form.FormBorderStyle = FormBorderStyle.None; //form.Parent = uIPanel; form.Parent = tabPage; //不可使用WindowState // form.WindowState = FormWindowState.Maximized; //设置最大高宽,最小高宽 form.MinimumSize = new Size(w, h); //填充pannel form.Dock = DockStyle.Fill; form.Show(); listForm.Add(form); mianTabContorl.SelectedTab = tabPage; } else { mianTabContorl.SelectedTab = GetTabPage(form.Name); } } catch (Exception ex) { Sunny.UI.Common.ShowErrorDialog("错误消息:" + ex.Message); } finally { Sunny.UI.Common.HideWaitForm(); } }
private TabPage GetTabPage(string name) { TabPage tb = null; foreach (TabPage item in mianTabContorl.TabPages) { if (item.Tag.ToString() == name) { tb = item; } } return tb; }
手机扫一扫
移动阅读更方便
你可能感兴趣的文章
4
5
6
7