We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Prevent one TabbedMDIManager tab from closing

Thread ID:

Created:

Updated:

Platform:

Replies:

89336 Aug 22,2009 12:21 AM Oct 12,2009 12:02 AM Windows Forms 10
loading
Tags: Tools
Dan Garvin
Asked On August 22, 2009 12:21 AM

I'm trying to prevent the user from closing the first tab. I don't event want the small close button showing up on that one tab, but the other tabs should be closable and should have the close button. Can't seem to find the right combination.

When my main MDI frame opens, I set the following properties:

TabbedMDIMgr.ShowCloseButton = true;
TabbedMDIMgr.AllowTabGroupCustomizing = false;

I then want an event to raise whenever I mouse over the first tab so I can set TabbedMDIMgr.ShowCloseButton = false; before the user even sees the little close button "x" on that first tab. Is this possible? I've tried handling several events. Here is the method that fires when a tab is added:

private void TabbedMDIManagerTabControlAdded(object sender, TabbedMDITabControlEventArgs args)
{
tabControl = args.TabControl;
args.TabControl.ControlAdded += TabControlControlAdded;
args.TabControl.MouseHover += TabControlMouseHover;
args.TabControl.MouseMove += TabControlMouseMove;
args.TabControl.SizeChanged += TabControlSizeChanged;
args.TabControl.SelectedIndexChanging += TabControlSelectedIndexChanging;
}

The bottom line is that I just want to prevent the close "x" from showing up on a single tab, named "Start". Thanks in advance for your suggestions.
-d




Dan Garvin
Replied On August 22, 2009 12:26 AM

A bit more info:

In the MouseHover event, tabControl only changes when I move from off the tabs to a given tab. It does not fire when moving my mouse from one tab across to another. This does appear to be the most promising. Close, but no ...

In the MouseMove event, I can see the mouse pointer coordinates change continuously as I move back and forth across tabs, but not sure how to make use of these coords. to determine which tab I'm on. Besides, as you move the mouse across to a new tab, the close button appears, changing the size of the tab, so mouse pointer coords may not be very helpful.

SelectedIndexChanging event only fires when you are clicking on a tab, not mousing over. Too late to affect the close button.
Thanks again.

Mano J [Syncfusion]
Replied On August 25, 2009 09:28 AM

Hi Dan,

You can do it only by setting ShowCloseButtonForActiveTabOnly property to true as shown below. Note that this will show the close button only for the active tab. If selected index is zero (first tab), hide the close button using ShowCloseButton property.

public Form1()
{
InitializeComponent();
tabbedMDIManager1.ShowCloseButton = true;
tabbedMDIManager1.ShowCloseButtonForActiveTabOnly = true;
tabbedMDIManager1.TabControlAdded += new TabbedMDITabControlEventHandler(tabbedMDIManager1_TabControlAdded);
}

private TabControlAdv tabcontrol;
private void tabbedMDIManager1_TabControlAdded(object sender, TabbedMDITabControlEventArgs args)
{
tabcontrol = args.TabControl;
tabcontrol.SelectedIndexChanged += new EventHandler(TabControl_SelectedIndexChanged);
}

void TabControl_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabcontrol.SelectedIndex == 0)
tabbedMDIManager1.ShowCloseButton = false;
else
tabbedMDIManager1.ShowCloseButton = true;
}

Regards,
Mano

Dan Garvin
Replied On September 9, 2009 11:06 PM

Thanks for the update. Yes, this works when the user CLICKS on the first tab. In fact, when the user clicks on the first tab (tab0) with this code, the "x" doesn't show up on not only the first tab, but it is displayed when I hover over any other tab.

The problem is this: Let's say the user clicks on the second tab. The close "x" is displayed on the second tab. Good. (See picture #1, attached.) If the user then moves the mouse over to the left and only hovers over tab0, the "x" pops up on the first tab. (See picture #2, attached.)

I'm trying to ensure the "x" doesn't even show up if the user hovers over the first tab, yet does show up hovering over any other tab. This is because the user can click on the popped up "x" of an unselected tab.

I've attached two pictures to describe the behavior I'm trying to prevent. Thanks.



tabClose2_5abbac6d.zip

Mano J [Syncfusion]
Replied On September 10, 2009 02:35 AM

Hi Dan,

Could you please let us know the Syncfusion version you are using, because we don't see this hovering problem in 7.3.0.20?

Regards,
Mano

Dan Garvin
Replied On September 25, 2009 11:08 AM

Currently on 5.1.1.47. I am planning on upgrading to the latest soon. Thanks.
-Dan

Dan Garvin
Replied On September 30, 2009 01:21 PM

Are you saying that if I upgrade to 7.x that I won't have this problem? Can you please elaborate and tell me what changed in 7.x to fix this? Thanks.
-dan

Nandakumar R [Syncfusion]
Replied On September 30, 2009 01:27 PM

Hi,

Thanks for your patience.

Yes, when you upgrade to the latest version, you will not have this issue.

This issue exists in the version 5.1 and this issue seems to be fixed the versions after 5.1. We are backtracking the details on the changes made for this and from which version this issue is fixed. I will get back to you tomorrow on the details of the fix made.

Thanks for your patience.

Regards,
Nanda

Nandakumar R [Syncfusion]
Replied On October 5, 2009 12:59 AM

Hi,

Thanks for your patience.

This issue has been fixed as part of the version 6.1.0.34. This fix is available with our latest versions and you can upgrade to the latest version here.

Thanks for your patience.

Regards,
Nanda

Dan Garvin
Replied On October 10, 2009 02:39 PM

Thanks. I upgraded to 7.3.0.20 and I can see a difference. I still need to test more, but it looks promising. Thanks again for your help.

Nandakumar R [Syncfusion]
Replied On October 12, 2009 12:02 AM

Hi,

Thanks for the update.

Regards,
Nanda

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;