Select Case e.Sender.Name Case "Label1","Label2","Label3","Label4" Dim Pnl As WinForm.Panel = e.Form.Controls("Panel" & e.sender.name.Replace("Label", "")) '合成 panel1、panel2、panel3或者panel4 这个字符 Pnl.Top = e.Sender.Top + e.Sender.Height + 3 '设置panel的纵坐标,等于label控件的纵坐标加上label控件的高度加3 Pnl.Visible = Not Pnl.Visible '如果panel之前显示,就隐藏,如果隐藏,就显示 e.sender.BaseControl.Image = IIf(Pnl.Visible, GetImage("control-270.png"),GetImage("control.png")) '设置图标 e.sender.BackColor = IIf(Pnl.Visible, Drawing.SystemColors.ControlDark, Drawing.SystemColors.Control) '设置背景颜色 Dim Lbl As WinForm.Label = e.Form.Controls("Label1") For i As Integer = 2 To 4 Pnl = e.Form.Controls("Panel" & i - 1) '获取对应的panel控件 e.Form.Controls("Label" & i).Top = IIF(Pnl.Visible,Pnl.Top + Pnl.Height + 3,Lbl.Top + Lbl.Height + 3) '设置panel的纵坐标 Lbl = e.Form.Controls("Label" & i) e.Form.Controls("Panel" & i).Top = Lbl.Top + Lbl.Height + 3 '根据对应label的纵坐标和高度设置panel控件的纵坐标 Next End Select
|