O'Reilly logo

Extreme Programming Adventures in C# by Ron Jeffries

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 26. Menu Arrays

As so often happens when we take a break, I got an idea about how to improve all that manual creation and searching of the insert menus. So I hurried home from lunch to share it with you.

The Pain

Even though we have improved the creation process for new menu items, it’s still not perfect. Every time we create a new insert menu item, we have to deal with the code that defines the item, the code that adds the item to the menu, and the code that looks up the item. Check the highlighted items in the following code from the XMLNotepad class, for example:

class XMLNotepad : Form { public TestableTextBox textbox; private TextModel model; private MenuItem insertPre; private MenuItem insertSection; private MenuItem insertUnorderedList; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required