Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 禁用form2以移出form1_Vb.net_Forms - Fatal编程技术网

Vb.net 禁用form2以移出form1

Vb.net 禁用form2以移出form1,vb.net,forms,Vb.net,Forms,我有两张表格。表格一及表格二 表格1为600x500,表格2为300x250 Form1总是打开的,当我打开form2时,它应该在Form1的顶部。如何禁用form2以移出宽度form1 像这样 不是这样的 因此,它应该可以重新调整大小,但不能从1的边缘移出 如果您不打算使用 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me

我有两张表格。表格一及表格二

表格1为600x500,表格2为300x250

Form1总是打开的,当我打开form2时,它应该在Form1的顶部。如何禁用form2以移出宽度form1

像这样

不是这样的


因此,它应该可以重新调整大小,但不能从1的边缘移出

如果您不打算使用

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.TopMost = True
    Me.Left = Form1.Location.X
    Me.Top = Form1.Location.Y + 30
End Sub

Private Sub Form2_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
    'check position
    Dim topLeft, topRight, bottomLeft, BottomRight As Point
    With Form1
        topLeft = New Point(.Location.X, .Location.Y + 30)
        topRight = New Point(.Location.X + .Width, .Location.Y + 30)
        bottomLeft = New Point(.Location.X, .Location.Y + .Height)
        'BottomRight = New Point(.Location.X + .Location.Y + .Height)
    End With
    Dim mytopLeft, mytopRight, mybottomLeft, myBottomRight As Point
    With Me
        mytopLeft = New Point(.Location.X, .Location.Y)
        mytopRight = New Point(.Location.X + .Width, .Location.Y)
        mybottomLeft = New Point(.Location.X, .Location.Y + .Height)
        'myBottomRight = New Point(.Location.X + .Location.Y + .Height)
    End With

    If topLeft.X > mytopLeft.X Then
        Me.Location = New Point(topLeft.X, Me.Location.Y)
        Me.Text = "topLeftX"
    End If
    If topLeft.Y > mytopLeft.Y Then
        Me.Location = New Point(Me.Location.X, topLeft.Y)
        Me.Text = "topLeftY"
    End If

    If topRight.X < mytopRight.X Then
        Me.Location = New Point(topRight.X - Me.Width, Me.Location.Y)
        Me.Text = "topRightX"
    End If

    If bottomLeft.Y < mybottomLeft.Y Then
        Me.Location = New Point(Me.Location.X, bottomLeft.Y - Me.Height)
        Me.Text = "bottomLeftY"
    End If
End Sub
Private Sub Form2\u Load(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理MyBase.Load
Me.TopMost=正确
Me.Left=Form1.Location.X
Me.Top=Form1.Location.Y+30
端接头
私有子窗体2_Move(ByVal sender作为对象,ByVal e作为System.EventArgs)处理Me.Move
“检查位置
将左上角、右上角、左下角、右下角变暗为点
表格一
左上=新点(.Location.X、.Location.Y+30)
右上角=新点(.Location.X+.Width,.Location.Y+30)
左下=新点(.Location.X、.Location.Y+.Height)
'BottomRight=新点(.Location.X+.Location.Y+.Height)
以
将mytopLeft、mytopRight、mybottomLeft、myBottomRight暗显为点
和我一起
mytopLeft=新点(.Location.X、.Location.Y)
mytopRight=新点(.Location.X+.Width.Location.Y)
mybottomLeft=新点(.Location.X、.Location.Y+.Height)
'myBottomRight=新点(.Location.X+.Location.Y+.Height)
以
如果topLeft.X>mytopLeft.X,则
Me.Location=新点(左上角的.X,Me.Location.Y)
Me.Text=“topLeftX”
如果结束
如果topLeft.Y>mytopLeft.Y,则
Me.Location=新点(Me.Location.X,左上角.Y)
Me.Text=“topLeftY”
如果结束
如果topRight.X
你想重新创造吗?@Bjørn RogerKringsjå感谢你的快速回答。看看这个。在表格1中,我设置IsMdiContainer=True。。添加一个菜单条,然后单击事件i添加此代码“
Private Sub-RosterManagementToolStripMenuItem\u单击(发件人作为对象,e作为事件参数)处理RosterManagementToolStripMenuItem。单击Dim f1作为新的FrmRoster f1.mdipparent=Me FrmRoster.Show()End Sub
”它仍然不会在里面打开,它在菜单条下面,看起来是这样的编辑:我只需要把菜单条锁定在屏幕上do@Bjørn RogerKringsjå我刚刚编辑。将MDI链接保留为答案,我将接受它。我是用MDI完成的。多亏了一个lotYes,您需要停靠MDI客户端的父控件。@Bjørn RogerKringsjå我用MDI子窗体完成了这个问题。如果你愿意的话,你可以把它作为答案贴出来,这样我就可以解决这个问题了。