本文介绍了如何使用C#中的箭头禁用WinForm导航?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我需要禁用更改表单上的箭头焦点。有没有一个简单的方法如何做到这一点? 谢谢 解决方案 prerivate $ Form1_Load(object sender,EventArgs e) { foreach(控制控制在this.Controls中) { control.PreviewKeyDown + = new PreviewKeyDownEventHandler(control_PreviewKeyDown); void control_PreviewKeyDown(object sender,PreviewKeyDownEventArgs e) { if(e.KeyCode == Keys.Up || e。 KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) { e.IsInputKey = true; } } I need to disable changing focus with arrows on form. Is there an easy way how to do it?Thank you 解决方案 Something along the lines of: private void Form1_Load(object sender, EventArgs e) { foreach (Control control in this.Controls) { control.PreviewKeyDown += new PreviewKeyDownEventHandler(control_PreviewKeyDown); } } void control_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) { e.IsInputKey = true; } } 这篇关于如何使用C#中的箭头禁用WinForm导航?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 16:30