- 积分
- 10812
- 明经币
- 个
- 注册时间
- 2004-6-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|

楼主 |
发表于 2025-8-30 11:11:04
|
显示全部楼层
修改源代码
' 主菜单按钮点击事件
AddHandler mainButton.Click,
Sub(sender, e)
' 如果点击的是当前已展开的菜单,则折叠它
If currentExpandedMenu IsNot Nothing AndAlso currentExpandedMenu Is subMenuPanel Then
currentExpandedMenu.Visible = False
将 currentMainButton.Text = "▶ " & CommandA.Title
修改为 currentMainButton.Text = "▼ " & CommandA.Title
currentExpandedMenu = Nothing
currentMainButton = Nothing
Else
' 否则,折叠当前已展开的菜单(如果有)
If currentExpandedMenu IsNot Nothing Then
currentExpandedMenu.Visible = False
currentMainButton.Text = "▶ " & currentMainButton.Text.Substring(2)
修改为 currentMainButton.Text = "▼ " & currentMainButton.Text.Substring(2)
End If
' 展开新的菜单
subMenuPanel.Visible = True
mainButton.Text = "▼ " & CommandA.Title
修改为 mainButton.Text = "▶ " & CommandA.Title
' 更新当前展开的菜单引用
currentExpandedMenu = subMenuPanel
currentMainButton = mainButton
End If
End Sub
自定义按钮的 Paint 事件
AddHandler mainButton.Paint,
Sub(sender, e)
Dim btn = CType(sender, Button)
Dim g = e.Graphics
g.Clear(btn.BackColor) ' 清除背景
' 绘制蓝色三角形
将 Dim triangleText = If(subMenuPanel.Visible, "▼", "▶")
修改为
Dim triangleText = If(subMenuPanel.Visible,, "▶" "▼")
|
|