2

右键单击时如何选择或聚焦某个标签页?

4

1 回答 1

1

实现 MouseDown 事件并找出点击了哪个选项卡:

    private void tabControl1_MouseDown(object sender, MouseEventArgs e) {
        if (e.Button == MouseButtons.Right) {
            for (int tab = 0; tab < tabControl1.TabCount; ++tab) {
                if (tabControl1.GetTabRect(tab).Contains(e.Location)) {
                    tabControl1.SelectedIndex = tab;
                    break;
                }
            }
        }
    }
于 2010-08-23T23:57:45.780 回答