自定义.net winforms菜单栏以打开“向上"? [英] Customise .net winforms menustrip to open 'upwards'?

查看:94
本文介绍了自定义.net winforms菜单栏以打开“向上"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我目前正在尝试实现自定义菜单栏,而不是将其菜单项绘制在菜单标题的下方,而宁愿将其直接绘制在菜单上方

例如代替

Hello all,
I am currently attempting to implement a custom menu strip, which instead of drawing it''s menu items with a tendency to be underneath the menu heading, instead prefers to draw them directly above

eg instead of

_________________
  |menuitem|
----|---------|--
    | item 1  |
    | item 1  |
    | item 1  |
    -----------



我们得到



we get

   ___________
   | item 1  |
   | item 1  |
   | item 1  |
-----------------
   |menuitem|
-----------------



我已经创建了一个自定义组件并继承了menustrip.
但是我被困在绘制"例程中,以覆盖它来更改菜单布局.

我可以找到很多信息,使菜单符合我喜欢的任何艳丽的颜色渐变,但是与重新放置菜单无关.
请帮忙!


忘了提一下,如果菜单栏停靠在窗体的底部,则它会按照我希望的方式运行,
但是,即使控件未停靠(即自由浮动),我也需要该控件以这种方式运行.



I''ve gotten as far as creating a custom component and inheriting menustrip.
But I''m stuck at what ''draw'' routine to override to change the menu layout.

I can find plenty of information to make the menu any gaudy colour gradient I like, but nothing much about repositioning the menu.
Help please!


Forgot to mention, the menu strip behaves the way I wish, if it is docked to the bottom of a form,
however, I need the control to operate in this manner even if it isn''t docked (ie free floating)

推荐答案

问题(请查看),再三考虑,我可以为您提供真正有用的建议,但不确定您是否会喜欢它.

您始终可以基于System.Windows.Forms.Control作为基础类实现所需的功能:将全新的菜单项类实现为派生类,使用覆盖的方法OnPaint呈现其内容,引入表示项数据以及与其他项之间关系的成员(例如作为Children).在其之上,实现一些Menu类.如果您只是为自己而做,则不必浪费时间在Designer之下的类的行为.

真的很难说是否可以自定义可用的菜单或菜单条控件,使其表现得像您想要的那样.可能不是.我个人几乎不会尝试,因为-我只能重复一遍-您的设计思想还不够疯狂,不足以引起人们的兴趣.好吧,上下颠倒的菜单,有什么好笑的?

—SA
Despite of my note in my comment to the question (please see it), on second thought, I can give you a really working advice, but not sure you will like it.

You can always implement desired functionality based on System.Windows.Forms.Control as a base class: implement a brand new menu item class as a derived class, render its content using overridden method OnPaint, introduce members representing item data and relationship with other items (such as Children). On top of it, implement some Menu class. And you don''t have to waste time on the behavior of your classes under the Designer, if you do it just for yourself.

It''s really hard to say if it would be possible to customize the available menu or menu strip control so much it would behave like you want. Probably not. I personally would hardly even try, because — I can only repeat — your design idea is not crazy enough to be interesting. Well, upside-down menu, what''s so funny?

—SA


这篇关于自定义.net winforms菜单栏以打开“向上"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆