停止箭头键滚动TabControl C#Winform上的选项卡

时间:2008-12-10 23:42:13

标签: c# winforms tabcontrol

我需要让箭头键无法滚动浏览各个标签。有人知道这样做的方法吗?

2 个答案:

答案 0 :(得分:0)

我使用以下代码解决了问题

string tempstring = e.KeyValue.ToString();
if (tempstring == "37" || tempstring == "38" || tempstring == "39" || tempstring == "40")
{
     e.Handled = true;
}

我将它放在tabControl1_KeyDown(对象发送者,KeyEventArgs e)方法中。

答案 1 :(得分:-1)

我认为您可以为该控件捕获事件“KeyPress”

然后在手柄上

System::Windows::Forms::KeyPressEventArgs^  e

然后检查

if (e->KeyChar == [find the number representing the arrow key])
  e->Handled = true; // Meaning that no one will receive it afterwards