/// <summary> /// Fires <see cref="TabStripItemClosing"/> event. /// </summary> /// <param name="e"></param> protected internal virtual void OnTabStripItemClosing(TabStripItemClosingEventArgs e) { if (TabStripItemClosing != null) { TabStripItemClosing(e); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) { return; } HitTestResult result = HitTest(e.Location); if (result == HitTestResult.MenuGlyph) { HandledEventArgs args = new HandledEventArgs(false); OnMenuItemsLoading(args); if (!args.Handled) { OnMenuItemsLoad(EventArgs.Empty); } ShowMenu(); } else if (result == HitTestResult.CloseButton) { if (SelectedItem != null) { TabStripItemClosingEventArgs args = new TabStripItemClosingEventArgs(SelectedItem); OnTabStripItemClosing(args); if (!args.Cancel && SelectedItem.CanClose) { RemoveTab(SelectedItem); OnTabStripItemClosed(EventArgs.Empty); } } } else if (result == HitTestResult.TabItem) { OMETabStripItem item = GetTabItemByPoint(e.Location); if (item != null) { SelectedItem = item; } } Invalidate(); }
private void tabControlObjHierarchy_TabStripItemClosing(TabStripItemClosingEventArgs e) { if (detailsTabs.Controls.Count == 1) e.Cancel = true; }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) return; HitTestResult result = HitTest(e.Location); if (result == HitTestResult.MenuGlyph) { HandledEventArgs args = new HandledEventArgs(false); OnMenuItemsLoading(args); if (!args.Handled) OnMenuItemsLoad(EventArgs.Empty); ShowMenu(); } else if (result == HitTestResult.CloseButton) { if (SelectedItem != null) { TabStripItemClosingEventArgs args = new TabStripItemClosingEventArgs(SelectedItem); OnTabStripItemClosing(args); if (!args.Cancel && SelectedItem.CanClose) { RemoveTab(SelectedItem); OnTabStripItemClosed(EventArgs.Empty); } } } else if (result == HitTestResult.TabItem) { OMETabStripItem item = GetTabItemByPoint(e.Location); if (item != null) SelectedItem = item; } Invalidate(); }
/// <summary> /// Fires <see cref="TabStripItemClosing"/> event. /// </summary> /// <param name="e"></param> protected internal virtual void OnTabStripItemClosing(TabStripItemClosingEventArgs e) { if (TabStripItemClosing != null) TabStripItemClosing(e); }