Can I remove the dotted focus rectangle over tabs on a TabControl?

不羁的心 提交于 2019-12-03 12:41:30

Set the focus to tab instead of header (like this)

private void tabControl1_Click(object sender, EventArgs e)
{
    (sender as TabControl).SelectedTab.Focus();
}

You will see dotted rectangle for a millisecond, as soon as the above event gets executed it will disappear.

Also, to remove dotted rectangle for default selected tab on load

private void tabControl1_Enter(object sender, EventArgs e)
{
    (sender as TabControl).SelectedTab.Focus();
}

Both this changes worked for me! hope it helps somebody.

Yes, DrawItem event. You didn't post it, impossible to guess what's wrong with it. Just make sure that you don't call e.DrawFocusRectangle(), likely to present when you copied the MSDN sample code. Simply deleting the statement is sufficient. Consider using a different background color or text font style as an alternative so the focus hint isn't entirely lost.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!