c# - 如何以编程方式显示 ContextMenuStrip 的 DropDown?
问题描述
我需要一个按钮来在鼠标左键单击而不是右键单击时显示与其关联的 ContextMenuStrip。我怎样才能做到这一点?
解决方案
试试下面的代码
Point location = button1.PointToScreen(Point.Empty);
contextMenuStrip1.Show(location);
PointToScreen 获取按钮的实际位置并显示按钮所在的上下文菜单条。
推荐阅读
- hyperledger-fabric - 在 Hyperledger Fabric 2 中部署链码时出错
- haskell - 使用 HaskellStack 安装包以与没有堆栈的 GHC 一起使用
- validation - Spring Batch:有没有办法继续验证跳过的行?
- c++ - 是否有一种代码预处理工具可以将多个用户定义的包含(无系统包含)合并到一个文件中?
- python - 访问 lru_cache 内部字典
- azure - 如何以纯文本形式从 Azure KeyVault 获取密钥?
- html - 为什么我的表单在 Chrome 中丢失了格式?
- python - 上传文件并从 Google 函数连接到 MongoDB 时,我需要什么类型的 API 或引用/命令?
- c# - 使用实体框架映射数据库的方法?
- amazon-web-services - 带有 pod 安全组的 EKS 上的 Traefik