'宣言 Public Class MaskedEditTool Inherits MaskedEditToolBase Implements Infragistics.Shared.IKeyedSubObject, Infragistics.Shared.IKeyedSubObjectEx, Infragistics.Win.IEditType, Infragistics.Win.Notifications.INotificationBadgeProvider, Infragistics.Win.Notifications.INotificationBadgeSettingsOwner
public class MaskedEditTool : MaskedEditToolBase, Infragistics.Shared.IKeyedSubObject, Infragistics.Shared.IKeyedSubObjectEx, Infragistics.Win.IEditType, Infragistics.Win.Notifications.INotificationBadgeProvider, Infragistics.Win.Notifications.INotificationBadgeSettingsOwner
Imports Infragistics.Win Imports Infragistics.Win.UltraWinToolbars Imports Infragistics.Win.UltraWinMaskedEdit Private Sub ultraButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ultraButton2.Click Dim maskTool As MaskedEditTool = New MaskedEditTool("Start Date") ' display the caption of the tool before the edit box maskTool.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText ' the caption will appear before the tool when the display style ' is ImageAndText or TextOnlyAlways maskTool.SharedProps.Caption = "Start Date:" ' when the tool is in edit mode and the end user copies some ' text, we want to include the literal characters maskTool.MaskClipMode = MaskMode.IncludeLiterals ' when editing though, we want the tool to display prompt ' characters and literals maskTool.MaskDisplayMode = MaskMode.IncludeBoth ' the mask edit tool supports all the masks that the ' EditorWithMask supports. in this case we want it to ' generate a date mask based on the current locale maskTool.MaskInput = "{date}" ' the spin buttons are optional and are not displayed by ' default. since we are using a date mask, we'll display ' the spin buttons as an additional way of modifying the ' day, month and year sections maskTool.SpinButtonDisplayStyle = SpinButtonDisplayStyle.OnRight ' use today's date as the initial value maskTool.Value = System.DateTime.Today ' when an editor tool has a shortcut, toolbarsmanager behaves ' like office does in that it will try to put a visible instance ' of the tool into edit mode. if there are no visible instances ' that can go into edit mode, the toolclick will be invoked. maskTool.SharedProps.Shortcut = System.Windows.Forms.Shortcut.CtrlD ' lastly we need to add the tool to the root tools collection ' this instance can be considered a template for when the ' end user creates more instances of the tools (using the ' runtime customizer) and is also the tool that will be ' invoked when its shortcut is pressed. Me.ultraToolbarsManager1.Tools.Add(maskTool) ' now we want to create an instance of this tool ' and place it on the main toolbar. the addtool method ' will return the instance of the tool that it put on ' the toolbar so we could modify its InstanceProps ' if necessary Dim toolInstance As MaskedEditTool = DirectCast(Me.ultraToolbarsManager1.Toolbars(0).Tools.AddTool("Start Date"), MaskedEditTool) ' if there are any tools before this tool instance on the ' toolbar then we want to draw a separator in front of it toolInstance.InstanceProps.IsFirstInGroup = True End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinToolbars; using Infragistics.Win.UltraWinMaskedEdit; private void ultraButton2_Click(object sender, System.EventArgs e) { MaskedEditTool maskTool = new MaskedEditTool("Start Date"); // display the caption of the tool before the edit box maskTool.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText; // the caption will appear before the tool when the display style // is ImageAndText or TextOnlyAlways maskTool.SharedProps.Caption = "Start Date:"; // when the tool is in edit mode and the end user copies some // text, we want to include the literal characters maskTool.MaskClipMode = MaskMode.IncludeLiterals; // when editing though, we want the tool to display prompt // characters and literals maskTool.MaskDisplayMode = MaskMode.IncludeBoth; // the mask edit tool supports all the masks that the // EditorWithMask supports. in this case we want it to // generate a date mask based on the current locale maskTool.MaskInput = "{date}"; // the spin buttons are optional and are not displayed by // default. since we are using a date mask, we'll display // the spin buttons as an additional way of modifying the // day, month and year sections maskTool.SpinButtonDisplayStyle = SpinButtonDisplayStyle.OnRight; // use today's date as the initial value maskTool.Value = System.DateTime.Today; // when an editor tool has a shortcut, toolbarsmanager behaves // like office does in that it will try to put a visible instance // of the tool into edit mode. if there are no visible instances // that can go into edit mode, the toolclick will be invoked. maskTool.SharedProps.Shortcut = System.Windows.Forms.Shortcut.CtrlD; // lastly we need to add the tool to the root tools collection // this instance can be considered a template for when the // end user creates more instances of the tools (using the // runtime customizer) and is also the tool that will be // invoked when its shortcut is pressed. this.ultraToolbarsManager1.Tools.Add(maskTool); // now we want to create an instance of this tool // and place it on the main toolbar. the addtool method // will return the instance of the tool that it put on // the toolbar so we could modify its InstanceProps // if necessary MaskedEditTool toolInstance = this.ultraToolbarsManager1.Toolbars[0].Tools.AddTool("Start Date") as MaskedEditTool; // if there are any tools before this tool instance on the // toolbar then we want to draw a separator in front of it toolInstance.InstanceProps.IsFirstInGroup = true; }