简体   繁体   English

获取光标位置在Windows应用程序中的另一种形式

[英]get cursor position another form in windows application

I have two form in my application i am calling two form together from master page.i wrote code in my master page in top i declared like this Dim form As New FrmDelivary Dim frm1 As New FrmrecievedDelivaryRequest 我的应用程序中有两种形式,我要从母版页一起调用两种形式。我在母版页的顶部写了代码,我声明像这样的Dim形式为New FrmDelivary Dim frm1作为New FrmrecievedDelivaryRequest

in toolstrip menu event like this: Dim frm1 As New FrmrecievedDelivaryRequest frm1.Location = New Point(625, 225) 在如下的工具栏菜单事件中:Dim frm1 As New FrmrecievedDelivaryRequest frm1.Location = New Point(625,225)
frm1.MdiParent = Me frm1.Show() frm1.MdiParent =我frm1.Show()

Dim frm2 As New FrmDelivary
frm2.Location = New Point(965, 0)
frm2.MdiParent = Me 
frm.show() 

if i press R i want to go my cursor the particular textbox of FrmrecievedDelivaryRequest 如果我按R键,我想将光标移到FrmrecievedDelivaryRequest的特定文本框

if i press D i want to go my cursor the particular textbox of FrmDelivary 如果我按D,我想将光标移至FrmDelivary的特定文本框

How can I do this? 我怎样才能做到这一点? i trey something like this in frmMaster_KeyDown event: but same page is showing again. 我在frmMaster_KeyDown事件中显示以下内容:但是同一页面再次显示。 I have already open instance of FrmDelivary, so I don't want to show same page again. 我已经打开了FrmDelivary的实例,所以我不想再次显示同一页面。 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

I am working on vb.net windows application 我正在vb.net Windows应用程序上工作

After

frm1.Show()

place 地点

frm1.txtTicket.Focus()

I don't think you need the Cursor.Position call 我认为您不需要Cursor.Position电话

Set your frm1 and frm2 variables at the top of the code window so they are accessible from all of the Subs. 在代码窗口的顶部设置frm1和frm2变量,以便可以从所有Subs中访问它们。 In your KeyDown event, put 在您的KeyDown事件中,

If e.KeyCode = Keys.A Then
    frm1.Show()
    frm1.txtTicket.Focus()
    Cursor.Position = frm1.txtTicket.Location
end if

The problem is that you are instantiating a new copy of the form with the "AS NEW frmDelivery" statement. 问题是您正在使用“ AS NEW frmDelivery”语句实例化表单的新副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM