TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
maples
NA
1
0
Custom MenuItem
Feb 5 2005 9:51 AM
Created simple class derived from MenuItem public class SauronMenuItem : System.Windows.Forms.MenuItem, IMenuItem { .... public SauronMenuItem(string Name, string Text, Image image, EventHandler onClick, Shortcut shortcut) : base(Text, onClick, shortcut) { OwnerDraw = false; _Name = Name; _Image = image; } protected override void OnMeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { base.OnMeasureItem(e); //temporrally fixedvalues e.ItemHeight = 32; e.ItemWidth = 75; } protected override void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { base.OnDrawItem(e); DrawText(e); } private void DrawText(System.Windows.Forms.DrawItemEventArgs e) { RectangleF TextRectF = new RectangleF(e.Bounds.X + 32, e.Bounds.Top, e.Bounds.Width - 48, e.Bounds.Height); ... e.Graphics.DrawString(Text, MenuFont, TextBrush, TextRectF, sf); } } When I try show ContextMenu then I get error "Out Of Memory". It happen after then method MenuItem.OnMeasureItem of last MenuItem called in ContextMenu. Same error happen if I add handlers to MeasureItem and DrawItem without override apropriate methods. Where is a bug? I hat i forgot did?
Reply
Answers (
1
)
Cant get Excel drag-n-drop to work. Please help.
GetOpenFileName in C#