问题描述
我的应用程序中有两个表单,我从母版页一起调用了两个表单.我在母版页中编写了代码在上面我这样声明Dim 窗体作为新 FrmDelivary将 frm1 调暗为新的 FrmrecievedDelivaryRequest
I have two form in my application i am calling two form together from master page.i wrote code in my master pagein top i declared like thisDim form As New FrmDelivaryDim frm1 As New FrmrecievedDelivaryRequest
在这样的工具条菜单事件中:Dim frm1 作为新的 FrmrecievedDelivaryRequestfrm1.Location = 新点(625, 225)
frm1.MdiParent = 我frm1.Show()
in toolstrip menu event like this: Dim frm1 As New FrmrecievedDelivaryRequest frm1.Location = New Point(625, 225)
frm1.MdiParent = Me frm1.Show()
Dim frm2 As New FrmDelivary
frm2.Location = New Point(965, 0)
frm2.MdiParent = Me
frm.show()
如果我按 R,我想将光标移到 FrmrecievedDelivaryRequest
if i press R i want to go my cursor the particular textbox of FrmrecievedDelivaryRequest
如果我按 D 我想将光标移到 FrmDelivary
if i press D i want to go my cursor the particular textbox of FrmDelivary
我该怎么做?我在 frmMaster_KeyDown
事件中尝试过类似的事情:但同一页面再次显示.我已经打开了 FrmDelivary 的实例,所以我不想再次显示相同的页面.我只想将光标位置定位到此表单的特定文本框
How can I do this? i trey something like this in frmMaster_KeyDown
event: but same page is showing again. I have already open instance of FrmDelivary, so I don't want to show same page again. I want to just get cursor position to particular textbox of this form
If e.KeyCode = Keys.A Then
form.Show()
form.txtTicket.Focus()
Cursor.Position = form.txtTicket.Location
end if
我正在开发 vb.net windows 应用程序
I am working on vb.net windows application
推荐答案
在代码窗口的顶部设置 frm1 和 frm2 变量,以便所有 Sub 都可以访问它们.在您的 KeyDown 事件中,输入
Set your frm1 and frm2 variables at the top of the code window so they are accessible from all of the Subs. In your KeyDown event, put
If e.KeyCode = Keys.A Then
frm1.Show()
frm1.txtTicket.Focus()
Cursor.Position = frm1.txtTicket.Location
end if
问题在于您正在使用AS NEW frmDelivery"语句实例化表单的新副本.
The problem is that you are instantiating a new copy of the form with the "AS NEW frmDelivery" statement.
这篇关于在 Windows 应用程序中获取另一个表单的光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!