This method, although it doesn't use binary search, handles Multiline tab pages too.
private static int
GetTabIndexAt
(
System.Windows.Forms.TabControl tabControl
,
System.Drawing.Point point
)
{
int result = -1;
if (tabControl != null)
{
for (int i = 0; i < tabControl.TabPages.Count; i++)
{
System.Drawing.Rectangle rect = tabControl.GetTabRect(i);
if (rect.Contains(point))
{
result = i;
break;
}
}
}
return (result);
}