Toolstripitem 始终位于菜单末尾
有谁知道有什么方法可以将工具条项目始终保留在菜单末尾吗? 无论添加或删除其他项目。
谢谢, 霍雷亚
Does anyone know any way of keeping an toolstripitem always at the end of the menu ?
regardless of adding or removing other items.
thanks,
Horea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要动态添加菜单项,请尝试在 ToolStrip 的 MenuItemCollection 中使用 AddAt() 而不是 Add()。将每个新菜单项添加到比集合大小小两倍的索引中,这样会将当前的最后一个 MenuItem 保留在最后。
在设计器中,您没有任何东西可以将某些内容保留在您创建的新内容之外,但您只需拖放即可将它们按照您想要的(初始)顺序排列。
您还可以使用各种布局属性。如果要将两个菜单合并在一起,则可以将 MergeAction 指定为 Insert,并使用 MergeIndex 指示新菜单的位置。您可以使用直接位于 ToolStrip 中的 ToolStripMenuItem 的 Alignment 属性将根菜单或菜单项放在菜单栏或工具条的右侧。
If you're adding menu items dynamically, try using AddAt() instead of Add() in the MenuItemCollection of the ToolStrip. Add each new menu item to the index two less than the size of the collection, and that'll keep the current last MenuItem last.
In the designer, you don't have anything to keep something to the outside of anything new you create, but you can just drag and drop to get them in the (initial) order you want.
You can also use various Layout properties. If you're merging two menus together, you can specify the MergeAction to be Insert, with a MergeIndex indicating where you'd like new ones to go. You can use the Alignment property of a ToolStripMenuItem located directly in a ToolStrip to put a root menu or menu item on the right side of the menu bar or toolstrip.