Dim pb As WinForm.Panel = Forms("菜单").Controls("Panel1")
Dim width As Integer = pb.width
Dim height As Integer = pb.height
Dim wh As Integer = width \ 105
Dim n As Integer = Tables("桌台信息").Rows.Count
Dim lbl As WinForm.panel
Dim lbl1 As WinForm.Label
Dim p As WinForm.PictureBox
Dim s, t As Integer
For i As Integer = 0 To n - 1
If i <> 0 Then
If i Mod wh = 0 Then
s = 0
t = t + lbl.Height + 10
Else
s = s +115
End If
End If
Dim r As Row = Tables("桌台信息").Rows(i)
Dim nm As String = r("序号")
Dim nm0 As String = r("桌台号")
lbl = Forms("菜单").CreateControl(nm, ControlTypeEnum.Panel)
lbl.name = nm
lbl.BackColor = Color.lightgray
lbl.Left = s
lbl.Top = t
lbl.Width = 105
lbl.Height = 90
Forms("菜单").Controls("panel1").AddControl(lbl)
lbl1 = Forms("菜单").CreateControl(nm0, ControlTypeEnum.Label)
lbl1.BackColor = Color.green
lbl1.ForeColor = Color.White
lbl1.Left = 0
lbl1.Top = 0
lbl1.Width = 105
lbl1.Height = 20
lbl1.Text = space(4) & nm0
lbl.AddControl(lbl1)
p = Forms("菜单").CreateControl(nm0, ControlTypeEnum.PictureBox)
p.name = nm0
p.Left = s
p.Top = t + 20
p.Width = 105
p.Height = 70
Forms("菜单").Controls("panel1").AddControl(p)
If TypeOf e.sender Is WinForm.SplitContainer Then
Else
Dim controlname As String
If TypeOf e.sender Is WinForm.Panel Then
controlname = e.sender.name
ElseIf e.sender.parent IsNot Nothing Then
If TypeOf e.sender.Parent Is WinForm.Panel Then
controlname = e.sender.parent.name
End If
End If
msgbox(controlname)
Vars("序号") = controlname
Dim n As Integer = Tables("桌台信息").Rows.Count
For i As Integer = 0 To n - 1
Dim r As Row = Tables("桌台信息").Rows(i)
Forms("菜单").Controls(r("序号")).BorderStyle = BorderStyle.None
Forms("菜单").Controls(r("序号")).BackColor = Color.Lightgray
Next
Forms("菜单").Controls(controlname).BorderStyle = BorderStyle.FixedSingle
Forms("菜单").Controls(controlname).BackColor = Color.Azure
End If
[此贴子已经被作者于2023/10/8 22:11:34编辑过]
lbl1 = Forms("菜单").CreateControl(nm0, ControlTypeEnum.Label)
lbl1.BackColor = Color.green
lbl1.ForeColor = Color.White
lbl1.Left = 0
lbl1.Top = 0
lbl1.Width = 105
lbl1.Height = 20
lbl1.Text = space(4) & nm0
lbl.AddControl(lbl1)
nm0怎么居中显示?
If TypeOf e.sender Is WinForm.SplitContainer Then 如果是分区控件
Else
Dim controlname As String
If TypeOf e.sender Is WinForm.Panel Then 如果点击是panel
controlname = e.sender.name 获取panel名称
ElseIf e.sender.parent IsNot Nothing Then 如果当前点击的控件有父控件
If TypeOf e.sender.Parent Is WinForm.Panel Then 如果父控件是panel
controlname = e.sender.parent.name获取父控件名称
End If
End If
msgbox(controlname)
Vars("序号") = controlname
Dim n As Integer = Tables("桌台信息").Rows.Count
For i As Integer = 0 To n - 1遍历所有行设置对应控件的边框和颜色
Dim r As Row = Tables("桌台信息").Rows(i)
Forms("菜单").Controls(r("序号")).BorderStyle = BorderStyle.None
Forms("菜单").Controls(r("序号")).BackColor = Color.Lightgray
Next
设置对应panel控件的边框和颜色
Forms("菜单").Controls(controlname).BorderStyle = BorderStyle.FixedSingle
Forms("菜单").Controls(controlname).BackColor = Color.Azure
End If
lbl1 = Forms("菜单").CreateControl(nm0, ControlTypeEnum.Label)
lbl1.BackColor = Color.green
lbl1.ForeColor = Color.White
lbl1.Left = 0
lbl1.Top = 0
lbl1.Width = 105
lbl1.Height = 20
lbl1.Text = space(4) & nm0
lbl.AddControl(lbl1)
nm0怎么居中显示? 好象with和字符length不一致,加四个空格比较接近中间,但名称有可能有长有短,加空格就不通用了
[此贴子已经被作者于2023/10/8 21:54:15编辑过]