Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

.NET WinForms and drawing menu items

Back to Forum: Tech Off
  • User profile image

    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

    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".

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.