Tech Off Thread

2 posts

.NET WinForms and drawing menu items

Back to Forum: Tech Off
  • User profile image
    object88

    I want to draw the contents of a ContextMenu menu item myself, but I can't get it to work.  I'm getting the event to draw, but the space to draw is in small.  The context menu itself is very small onscreen, and irregardless of where the menu item is in the menu, the DrawItemEventArgs.Bounds X and Y are always at 0.

    I have tried a menu with two user-drawn menu items and no system-drawn items, and one where only the first was user-drawn (with many system-drawn ones after).

    It seems like the system does not know how much space to give the menu item to draw in, so it gives almost nothing.  It also doesn't seem to want to keep track of the menu item offset (or is that something I'm supposed to do, with the DrawItemEventArgs.Index property?)

    None of the MSDN examples I've found seem to do anything my own code is doing, so I'm at a loss.  Help?

  • User profile image
    object88

    Nevermind; just found the MeasureItem event.  This should really be put into the DrawItem documentation or example, and I don't just mean a link to it at the botton.  Something more like "if you don't also implement the MeasureItem event, you're wasting your time".

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.