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. Image for the cookie policy date
close icon

TabControl tell if tab changes by user click or programmatically

When using a TabControlAdv, we allow the user to select a tab. We perform some other actions when the user selects a tab. Also, we sometimes programmatically select a tab. When that happens, we need different things to happen than when a user clicks on a tab (and, also, we don't want an infinite loop).

Is there a way to tell the difference between having a user select a new tab and changing a selected tab programmatically? I've been using the SelectedIndexChanging event to catch when the user selects a new tab, but that means I have to keep disabling and enabling the event handler when I programmatically change the tab.

1 Reply

RB Rajasekar B Syncfusion Team March 1, 2010 11:55 AM UTC

Hi,

In SelectedIndexChanged event,you can find whether the tab is selected by mouse or through code using the below workaround:

int i = this.tabControlAdv1.Renderer.HitTestTabs(this.tabControlAdv1.PointToClient(MousePosition), false);

This will return selected index. If the value of i is -1 then it indicates it is selected through code. If it returns exact selected index then it is selected by mouse.

Please let me know if this helps you.

Thanks,
Rajasekar

Loader.
Live Chat Icon For mobile
Up arrow icon