public void Add(string text) { MyTabPage tp = new MyTabPage(); tp.Text = text; Add(tp); }
public void Add(MyTabPage page) { tabPages.Add(page); page.Size = new Size(tabContainer.Width, tabContainer.Height - 32); page.Location = new Point(0, 32); page.TextChanged += new MyTabPage.TextChangedEventHandler(tabContainer.TabPage_TabTextChanged); page.Show(); tabContainer.Controls.Add(page); tabContainer.Refresh(); }
protected void DrawItem(DrawItemEventArgs e) { Image closeButton = MyPad.Properties.Resources.CloseIcon; MyTabPage tab = this.TabPages[e.Index]; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e.Graphics.FillRectangle(new SolidBrush(SystemColors.Control), e.Bounds); e.Graphics.DrawLine(new Pen(SystemColors.ControlLightLight, 1), new Point(e.Bounds.Left, e.Bounds.Top), new Point(e.Bounds.Right, e.Bounds.Top)); e.Graphics.DrawLine(new Pen(SystemColors.ControlDarkDark, 1), new Point(e.Bounds.Right, e.Bounds.Top), new Point(e.Bounds.Right, e.Bounds.Bottom - 2)); e.Graphics.DrawImage(closeButton, new Rectangle(e.Bounds.Right - 18, e.Bounds.Top + 5, 14, 14)); } TextRenderer.DrawText(e.Graphics, tab.Text, e.Font, e.Bounds, this.ForeColor, Color.Transparent, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); }
protected override void OnMouseClick(MouseEventArgs e) { for (int i = 0; i < this.TabPages.Count; i++) { Rectangle rect = GetTabRect(i); Rectangle mouseRect = new Rectangle(e.X, e.Y, 1, 1); if (e.Y >= rect.Top && e.Y <= rect.Bottom) { if (e.X >= rect.Left && e.X <= (rect.Right - 18)) { this.SelectedTabPage = this.TabPages[i]; } else if (e.X >= (rect.Right - 18) && e.X <= rect.Right) { MyTabPage tab = this.TabPages[i]; if (tab == selectedTabPage) { bool closeTab = true; TabClosing(tab, ref closeTab); if (closeTab) { this.TabPages.Remove(tab); tab.Dispose(); } } } this.Refresh(); } } base.OnMouseClick(e); }
public void Remove(MyTabPage page) { tabPages.Remove(page); }
public int IndexOf(MyTabPage page) { return(tabPages.IndexOf(page)); }