设置所有打开表单的位置 [英] set the location of all open forms
本文介绍了设置所有打开表单的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这段代码让我可以在每次拖动地图时设置 form
的位置.
this code lets me set the location of the form
each time I drag my map.
Private Sub map_OnMapDrag() Handles map.OnMapDrag
If f2c1.Visible Then
f2c1.Location = camera1.LocalPosition + New Point(20, -240)
End If
If f2c2.Visible Then
f2c2.Location = camera2.LocalPosition + New Point(20, -240)
End If
If f2c3.Visible Then
f2c3.Location = camera3.LocalPosition + New Point(20, -240)
End If
End Sub
但是,我希望它在公共潜艇上..
however, I want it on a public sub..
还有这段代码,我认为它可以所有可见 表单
..
and this code, which I think gets all the visible forms
..
Dim forms = Application.OpenForms.OfType(Of frmCamera)()
While forms.Count > 0
forms(forms.Count - 1).Visible = True
End While
我怎样才能让所有可见表单在每次拖动时都能获得它们的位置,这样即使我动态添加了另一个表单
,它也不会是一个问题.这就是我的目标.
how can I make it so that all visible forms gets their location everytime I drag it, so that even if I dynamically added another form
it won't be a problem. that's my goal.
你们能帮我解决这个问题吗..
can you guys fix this for me..
Dim forms = Application.OpenForms.OfType(Of frmCamera)()
While forms.Count > 0
forms(forms.Count - 1).Visible = True
End While
forms.Location = 'location that I want
推荐答案
试试这个:
Dim forms As Collections.Generic.IEnumerable(Of frmMain) = Application.OpenForms.OfType(Of frmMain).Where(Function(frm) frm.Visible)
For Each f As Form In forms
f.Location = New Point(0, 0) ' set coordinate as needed
Next
这篇关于设置所有打开表单的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文