好了,谢谢老师!
Dim e = Args(0)
Dim s As String = Args(1)
Dim 控件名称 As String = Args(2)
Dim a As System.Windows.Forms.AnchorStyles
For Each ss As String In s.Split("|")
a = a Or [Enum].Parse(GetType(System.Windows.Forms.AnchorStyles), ss)
Next
Args(0).Form.Controls(控件名称).Anchor = a
'Functions.Execute("_Anchor2", e, "Top|Bottom|Left|Right", "TextBox1")
我还用另一种方法写了一版
Dim e = Args(0)
Select Case Args(2)
Case 1
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left, System.Windows.Forms.AnchorStyles) '上左
Case 2
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles) '上右
Case 3
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles) '下右
Case 4
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left, System.Windows.Forms.AnchorStyles) '下左
Case 5
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left, System.Windows.Forms.AnchorStyles) '上下左
Case 6
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles) '上左右
Case 7
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles) '上下右
Case 8
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles) '下左右
Case 9
Args(0).Form.Controls(Args(1)).Anchor = CType(System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles) '上下左右
End Select
'数字顺序是由左到下顺时针旋转
'Functions.Execute("_Anchor", e, 控件名称, 控件位置)
'Functions.Execute("_Anchor", e, "TextBox1", 3)