DropDownButton下拉菜单位置问题vb.net

rmini 2011-07-23 01:01:34
通常下拉菜单是在DropDownButton1的下方,我的意思是如果窗体变化时,DropDownButton1在窗体底部时,DropDownButton1的底部至屏幕底部之间显示不了菜单,菜单则显示在DropDownButton1的上方,以下是我的代码,有点问题,一是点击下拉箭头时下拉菜单在屏幕最左上角仿佛有闪一下的感觉,二是位置还是有点不对,望各位高人给以指点(DropDownButton1绑定菜单ContextMenuStrip1)

Private Sub DropDownButton1_ArrowButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownButton1.ArrowButtonClick
ContextMenuStrip1.Show()
If My.Computer.Screen.Bounds.Bottom.ToString - Me.PointToScreen(DropDownButton1.Location).Y > Me.ContextMenuStrip1.Height Then
Me.ContextMenuStrip1.Left = Me.PointToScreen(DropDownButton1.Location).X
Me.ContextMenuStrip1.Top = Me.PointToScreen(DropDownButton1.Location).Y + Me.DropDownButton1.Height
Else
Me.ContextMenuStrip1.Left = Me.PointToScreen(DropDownButton1.Location).X
Me.ContextMenuStrip1.Top = Me.PointToScreen(DropDownButton1.Location).Y - ContextMenuStrip1.Height
End If
End Sub
...全文
895 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
rmini 2011-07-23
  • 打赏
  • 举报
回复
If My.Computer.Screen.WorkingArea.Height - Me.PointToScreen(DropDownButton1.Location).Y - Me.DropDownButton1.Height > Me.ContextMenuStrip1.Height Then

非常谢谢bw555
rmini 2011-07-23
  • 打赏
  • 举报
回复
非常谢谢!菜单感觉闪的问题解决了,但是还是有菜单遮住整个DropDownButton1的情况,我的意思是要么菜单都在DropDownButton1的上方,要么都在DropDownButton1的下方
bw555 2011-07-23
  • 打赏
  • 举报
回复
    Private Sub DropDownButton1_ArrowButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownButton1.ArrowButtonClick
Dim V_TOP As Single
If My.Computer.Screen.Bounds.Bottom.ToString - Me.PointToScreen(DropDownButton1.Location).Y > Me.ContextMenuStrip1.Height Then
V_TOP = Me.DropDownButton1.Height
Else
V_TOP = -ContextMenuStrip1.Height
End If
ContextMenuStrip1.Show(Me.DropDownButton1, 0, V_TOP)
End Sub

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧