CHAPTER 19 BUILDING A BETTER WINDOW WITH (Web hosting compare)

CHAPTER 19 BUILDING A BETTER WINDOW WITH SYSTEM.626 STEM.WINDOWS.FORMS Application.Run(new MainWindow()); } } Note The [STAThread] attribute instructs the CLR to host any legacy COM objects (including ActiveX controls) in a single-threaded apartment (STA). If you have a background in COM, you may recall that the STA was used to ensure access to a COM type occurred in a synchronous (hence, thread-safe) manner. Autoreferenced Assemblies Finally, if you examine Solution Explorer, you will notice that aWindows Forms project automatically references a number of assemblies, including System.Windows.Forms.dll and System.Drawing.dll. Again, the details of System.Drawing.dll will be examined in the next chapter. Working with MenuStrips and ContextMenuStrips As of .NET 2.0, the recommended control for building a menu system is MenuStrip. This control allows you to create normal menu items such as File .Exit, and you may also configure it to contain any number of relevant controls within the menu area. Here are some common UI elements that may be contained within a MenuStrip: ToolStripMenuItem: A traditional menu item ToolStripComboBox: An embedded ComboBox ToolStripSeparator: A simple line that separates content ToolStripTextBox: An embedded TextBox Programmatically speaking, the MenuStrip control contains a strongly typed collection named ToolStripItemCollection. Like other collection types, this object supports members such as Add(), AddRange(), Remove(), and the Count property. While this collection is typically populated indirectly using various design-time tools, you are able to manually manipulate this collection if you so choose. To illustrate the process of working with the MenuStrip control, create a new Windows Forms application named MenuStripApp. Using the Forms designer, place a MenuStrip control named mainMenuStrip onto your Form. When you do so, your *.Designer.cs file is updated with a new MenuStrip member variable: private System.Windows.Forms.MenuStrip mainMenuStrip; MenuStrips can be highly customized using the Visual Studio 2005 Forms designer. For example, if you look at the extreme upper-left of the control, you will notice a small arrow icon. After you select this icon, you are presented with a context-sensitive inline editor, as shown in Figure 19-11.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Leave a Reply