CHAPTER 19 BUILDING A BETTER WINDOW WITH (Tomcat web server)
Tuesday, June 10th, 2008CHAPTER 19 BUILDING A BETTER WINDOW WITH SYSTEM.630 STEM.WINDOWS.FORMS Go ahead and take your updated application out for another test drive and try entering in the names of various colors. Once you do, you should see your Form s background color change. If you are interested in checking out some valid color names, look up the System.Drawing.Color type using the Visual Studio 2005 Object Browser or the .NET Framework 2.0 SDK documentation. Creating a Context Menu Let s now examine the process of building a context-sensitive pop-up (i.e., right-click) menu. Under .NET 1.1, the ContextMenu type was the class of choice for building context menus, but under .NET 2.0 the preferred type is ContextMenuStrip. Like the MenuStrip type, ContextMenuStrip maintains a ToolStripItemCollection to represent the possible subitems (such as ToolStripMenuItem, ToolStripComboBox, ToolStripSeperator, ToolStripTextBox, etc.). Drag a new ContextMenuStrip control from the Toolbox onto the Forms designer and rename the control to fontSizeContextStrip using the Properties window. Notice that you are able to populate the subitems graphically in much the same way you would edit the Form s main MenuStrip (a welcome change from the method used in Visual Studio .NET 2003). For this example, add three ToolStripMenuItems named Huge, Normal, and Tiny (see Figure 19-14). This context menu will be used to allow the user to select the size to render a message within the Form s client area. To facilitate this endeavor, create an enum type named TextFontSize within the MenuStripApp namespace and declare a new member variable of this type within your Form type (set to TextFontSize.FontSizeNormal): namespace MainForm { // Helper enum for font size. enum TextFontSize { FontSizeHuge = 30, FontSizeNormal = 20, FontSizeTiny = 8 } public class MainForm : Form { Figure 19-14. Designing a ContextMenuStrip
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.