Dim w,h,j,w0,w1,h0,h1 As Integer
w = 80 '控件宽
h = 50 '控件高
w0=10 '左右外边距
w1=5 '左右内边距
h0=10 '上外边距
h1=7 '上下内边距
j= e.Form.Width-w0+w1
j=j\(w+w1)
Dim drs As List(Of DataRow)
drs = DataTables("表a").Select("[状态] = '在线'")
For i As Integer = 1 To drs.Count
If e.Form.ExistControl("online_Panel" & i) = True
e.Form.RemoveControl("online_Panel" & i)
End If
Dim pl As WinForm.Panel
pl = e.Form.CreateControl("online_Panel" & i, ControlTypeEnum.Panel)
pl.Width = w
pl.Height = h
pl.Left = w0+((i-1) Mod j)*(w+w1)
pl.Top = h0+((i-1)\j)*(h+h1)
e.Form.Controls("Panel1").AddControl(pl)
If e.Form.ExistControl("online_Panel" & i & "_" & drs(i-1)("用户")) = True
e.Form.RemoveControl("online_Panel" & i & "_" & drs(i-1)("用户"))
End If
Dim pt As WinForm.Painter
pt = e.Form.CreateControl("online_Panel_" & i & "_" & drs(i-1)("用户"), ControlTypeEnum.Painter)
pt.Width = w
pt.Height = h
pt.Left= 0
pt.Top = 0
pt.BorderStyle = BorderStyle.Fixed3D
pl.BackColor = color.pink
e.Form.Controls("online_Panel" & i).AddControl(pt)
Dim g As Graphics = pt.Graphics
Dim fnt As New Font("黑体",10,FontStyle.Bold)
Dim s1 As String = drs(i-1)("用户")
g.DrawString(s1,fnt,Brushes.black,10,10) '定义启始为止
g.DrawImage(getImage(drs(i-1)("图像")),10,30)
pt.Repaint()
Next