使用箭头键在窗体上的图片框之间导航 [英] Navigate between picture boxes on a form using Arrow Keys

查看:101
本文介绍了使用箭头键在窗体上的图片框之间导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的表格上有这样的结构.窗体包含TableLayout,TableLayout中的每个单元格都包含面板,每个面板内部都有一个PictureBox和一个Label.用户选择方向导航"时,模式下,他/她可以选择使用方向键在窗体上的PictureBox之间进行导航.我在不同的图片框之间进行了自动对焦调整,但无法使用方向键进行调整.请帮忙!

Hi,
I have a structure on my Form like this. Form contains TableLayout, each cell in TableLayout contains Panel, each Panel has a PictureBox and a Label inside it. When the user selects the "Directional Navigation" mode, he/she is given an option to navigate between PictureBoxes on the Form using the Direction Keys. I did automatic shifiting of focus between different picture boxes but haven''t been able to do this using direction keys. Please help!

推荐答案

根据您的导航顺序在图片框上设置简单的标签索引.
然后将表单的关键预览设置为true.
然后在表单的按键事件中在vb.net中编写以下代码


如果e.KeyChar = Chr(Keys.Left)然后
EnterEqvTabL()
Elseif e.KeyChar = Chr(Keys.Right)然后
EnterEqvTabR()
其他
e.Handled = True
如果结束



定义方法

公共子EnterEqvTabL()
SendKeys.Send("{TAB}")
结束子



公共子EnterEqvTabR()
SendKeys.Send("{SHIFT + TAB}")
结束Sub
simple set tab index on pictureboxes as per ur navigation sequence.
then set key preview of form to true.
then on keypress event of the form write the following code in vb.net


If e.KeyChar = Chr(Keys.Left) Then
EnterEqvTabL()
Elseif e.KeyChar = Chr(Keys.Right) Then
EnterEqvTabR()
else
e.Handled = True
End If



define methodes

Public Sub EnterEqvTabL()
SendKeys.Send("{TAB}")
End Sub



Public Sub EnterEqvTabR()
SendKeys.Send("{SHIFT + TAB}")
End Sub


对不起,亲爱的,
现在,如果您没有固定任何图片框,则使用它们的名称数组(使用它们的名称数组)对它们进行聚焦.
..
像在负载上一样关注pb1
然后在左侧单击,将其聚焦在pb(x + 1)上,依此类推
.
如果正确,则pb(x-1)....

好吧,如果您动态地使用图片框,那么您可以使用一个分组框或面板,在其中放置/确定所有图片框并进行foreach调用并设置其焦点..

有帮助吗?
通过评论
..
sorry dear,
now if u have fixed no of pictureboxes then focus them using their name property using a array of their names.
..
like on load focus on pb1
then on left click focus it on pb(x+1) and so on
.
lese if right then pb(x-1) ....

ok if dynamically u r using picture boxes then u can take a groupbox or a panel where u put/cerate all pic boxes and in a foreach call and set their focus..

is it helpful..
pass a comment
..


这篇关于使用箭头键在窗体上的图片框之间导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆