Winform 2.0中的Strip控件

http://msdn.microsoft.com/msdnmag/issues/05/05/EnhancedWindowsForms/default.aspx
including MenuStrip, ToolStrip, StatusStrip, and ContextMenuStrip
Figure 9 Strip Controls

The new strip controls improve on MainMenu, ToolBar, StatusBar, and ContextMenu in several key ways, including:

  • A consistent API to all strip controls
  • Improved design-time experience
  • Allowing adjacent strip controls to be repositioned with respect to one another, as well as repositioned to the top, right, bottom, and left of the host form's client area
  • Contemporary look of Office 2003 and Windows themes
  • Ability to host a rich set of child controls, such as dropdown lists, labels, menus, and textboxes
  • Rendering support that simplifies custom painting coding

While MainMenu, ToolBar, StatusBar, and ContextMenu are not included by default in the Visual Studio Toolbox, they are still included in the .NET Framework, primarily for backwards compatibility. Of course, the strip controls are located on the Toolbox so you can easily drag them onto your form. Through the Designer, you can add a variety of controls to each strip control

Figure 10 Controls Hosted by Strip Control

Strip Control Designer-Allowed Strip Item Controls
MenuStrip ToolStripMenuItem (for both top menu and submenu items)
ToolStripComboBox
ToolStripTextBox
ToolStripSeparator (for submenus)
ContextMenuStrip Same as MenuStrip
ToolStrip ToolStripButton
ToolStripComboBox
ToolStripSplitButton
ToolStripLabel
ToolStripSeparator
ToolStripDropDownButton
ToolStripTextBox
ToolStripProgressBar
StatusStrip ToolStripStatusLabel
ToolStripProgressBar
ToolStripDropDownButton
ToolStripSplitButton

Figure 11 Key Strip Control Property Configurations

Property Description
AllowItemReorder Users can reposition strip items by setting this property to True. The user needs to press Alt before repositioning (not for ContextMenuStrip).
ShowItemToolTips Sets whether strip items can also display tool tips (not for MenuStrip or Context MenuStrip).
Dock Specifies the form edge to line the strip control up against or fill.
RenderMode Strip controls support three render modes:
System: rendered with colors from the system palette.
Professional: rendered according to the current Windows Color Scheme—Blue, Olive Green, or Silver.
ManagerRenderMode: rendered using the Windows Theme sensitive ToolStripRenderer and is the default.
Custom is currently unsupported.
SizingGrip Specifies whether the form sizing grip should be shown or hidden (StatusStrip only).
GripStyle Specifies whether a MenuStrip or ToolStrip displays a grip allowing it to be repositioned.
CanOverflow When the form becomes narrower than a strip control, this option specifies how to visually represent strip items that are hidden by the overlap, either hidden if False or accessible via a dropdown at the end of the strip control if True.


Figure 12 Key Strip Item Control Property Configurations

Property Description
DisplayStyle Specifies what to display; values include None, Text, Image, and ImageAndText.
TextImageRelation Sets the position of text in relation to an image. Applied when DisplayStyle is ImageAndText.
ImageScaling Specifies how an image is rendered, either ShrinkToFit or None.
Alignment Determines which end of a strip control a strip item control will align to, either Head or Tail (Left or Right sides, respectively, when rendering left-to-right).
Overflow Determines how each strip item control responds to overflow. Can be either Never, Always, or AsNeeded, which leaves the decision up to the host strip control.


Figure 16 Key MaskedTextBox Properties

Property Description
HidePromptOnLeave True by default but, if set to False, ensures that prompt characters are always visible.
PromptChar Used to change the prompt character. Underscore by default.
AllowPromptAsInput In some cases, your prompt character may also be a valid value and setting AllowPromptAsInput to True allows this when neither can be reasonably changed.
IncludeLiterals Specifies whether to include literal character values in MaskedTextBox's Text property.
IncludePrompts Specifies whether to include prompt character values in MaskedTextBox's Text property.
ResetOnPrompt If True, when a prompt is entered, a prompt is inserted and values on the right-hand side are shifted right.
ResetOnSpace If True, when a space is entered, a space is inserted and values on the right-hand side are shifted right.

posted on 2005-04-17 09:18  enjoy .net  阅读(836)  评论(0编辑  收藏  举报