Hi,
I've a TabControl with two Tabs. Now I want to drag something on one tab and if I drag over the TabHeader, the ActiveTab should change.
How can I find out, on which TabHeader I am ?
Thanks
Hansjörg Wintermantel
Hansjörg,
You would have to get the UIElement from the current mouse position and check to see if you can get a tab element, then mark it as selected if it is not already. The following code should cover this:
private void ultraTabControl1_DragOver(object sender, DragEventArgs e){ Point clientPt = this.ultraTabControl1.PointToClient(new Point(e.X, e.Y)); TabItemUIElement tabItemElement = this.ultraTabControl1.UIElement.ElementFromPoint(clientPt) as TabItemUIElement; if (tabItemElement != null) { UltraTab tab = (UltraTab)tabItemElement.TabItem; if (!tab.Selected) tab.Selected = true; }}
-Matt
Hi Matt,
works fine.
Hansjörg
FYI, there is an easier way to find the tab at a specified location in client coordinates: by using the TabFromPoint method on the UltraTabControl. The original code posted will work just as well though.