'删除指定容器内的按钮-------------------------------------------------------------------------------------------
For Each ctr As WinForm.Control In e.Form.Controls("Panel1").Children '遍历当前窗口指定容器(分区面板的面板1)的控件
If Typeof ctr Is WinForm.Button Then '如果判断正确 (判断变量是否是某类型的语法是:Typeof 变量 Is 类型)
e.Form.RemoveControl(ctr.name) '删除当前窗口指定容器内的指定控件
End If
Next
'根据指定表指定列内容生成按钮名称,并添加到指定容器--------------------------------------------------------------
Dim anmc As List(Of String) = DataTables("表B").GetValues("纵向按钮","纵向可见 = 1","排序") '指定列中提取不重复的值到集合中,并指定列排序
Dim ckgd As Single = e.Form.Height '获取当前窗口高度
Dim ansl As Integer = anmc.Count '获取需要生成的按钮数量
Dim angd As Single = (ckgd-(ansl + 1) * 5) / ansl '设置当前按钮高度
Dim i As Integer = 0
For Each mc As String In anmc
Dim an As WinForm.Button
an = e.Form.CreateControl(mc,ControlTypeEnum.Button)
an.FlatStyle = FlatStyle.Standard '设置按钮样式
an.VisualStyle = 2 '设置按钮风格,可选值(1-5)
an.Font = New Font("微软雅黑",13,FontStyle.Regular) '设置字体
an.ForeColor = Color.White '设置按钮字体颜色
an.SetBounds(5,5+i*(angd + 5), 150, angd) '设置按钮水平左边距,垂直,宽度,高度
i = i + 1
an.TextAlign = ContentAlignment.MiddleCenter '设置文本对齐方式
an.Text = mc
an.name = mc
e.Form.Controls("Panel1").AddControl(an) '将控件添加到指定面板1
Next