private void editorPane1_OnTabClose(object sender, TabCloseEventArgs e) { if (editorPane1.TabPages.Count == 1) { // e.Accept = false; } //editorPane1.SelectTab(e.TabIndex); TabPage tp = (TabPage)sender; if (editorPane1.TabPages.ContainsKey(tp.Name) && tp.Controls.Count > 0) { MarketCatalogue market = marketCat.Find(x => x.MarketId == tp.Name); marketUpdate.RemoveMarket(market.MarketId); MarketBook mb =new MarketBook(); marketUpdate.LastBooks.TryRemove(market.MarketId, out mb); markets.Remove(tp.Name); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) return; dragSource = GetTabIndex(e.X, e.Y); Rectangle rect = GetTabRect(dragSource); rect = GetCloseButtonRect(rect, dragSource == SelectedIndex); Point pt = new Point(e.X, e.Y); if (rect.Contains(pt)) { TabPage page = TabPages[dragSource]; TabCloseEventArgs ea = new TabCloseEventArgs(); ea.TabIndex = dragSource; ea.TabText = TabPages[dragSource].Text; ea.Accept = true; if (OnTabClose != null) OnTabClose(page, ea); if (ea.Accept) TabPages.RemoveAt(dragSource); } }