Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / MaskedTextBoxTextEditor.cs / 1 / MaskedTextBoxTextEditor.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing.Design;
using System.Diagnostics;
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.MaskedTextBoxTextEditor..ctor()")]
namespace System.Windows.Forms.Design
{
class MaskedTextBoxTextEditor : UITypeEditor
{
public MaskedTextBoxTextEditor()
{
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorSvc = null;
if (context != null && context.Instance != null && provider != null)
{
editorSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (editorSvc != null && context.Instance != null)
{
MaskedTextBox mtb = context.Instance as MaskedTextBox;
// If multiple instances selected, mtb will be null.
if( mtb == null )
{
mtb = new MaskedTextBox();
mtb.Text = value as string;
}
MaskedTextBoxTextEditorDropDown dropDown = new MaskedTextBoxTextEditorDropDown(mtb);
editorSvc.DropDownControl(dropDown);
if (dropDown.Value != null)
{
value = dropDown.Value;
}
}
}
return value;
}
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.DropDown;
}
return base.GetEditStyle(context);
}
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return false;
}
return base.GetPaintValueSupported(context);
}
public override bool IsDropDownResizable
{
get
{
return false;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeAttributeArgumentCollection.cs
- MachineKey.cs
- StringKeyFrameCollection.cs
- Convert.cs
- ImageListUtils.cs
- QualificationDataItem.cs
- KeysConverter.cs
- RawUIStateInputReport.cs
- TogglePattern.cs
- NonParentingControl.cs
- AnimatedTypeHelpers.cs
- JsonXmlDataContract.cs
- Renderer.cs
- LoginStatusDesigner.cs
- Array.cs
- DeferredSelectedIndexReference.cs
- FileSecurity.cs
- UrlMappingsSection.cs
- NullableDoubleMinMaxAggregationOperator.cs
- SingleSelectRootGridEntry.cs
- UpdatePanelTrigger.cs
- MetadataUtilsSmi.cs
- CodeTypeParameterCollection.cs
- HtmlHistory.cs
- EncodingDataItem.cs
- ItemDragEvent.cs
- PriorityRange.cs
- WindowsGrip.cs
- DiscreteKeyFrames.cs
- IndexerNameAttribute.cs
- XsdDateTime.cs
- SaveWorkflowAsyncResult.cs
- ErrorFormatterPage.cs
- EncryptRequest.cs
- DesignTimeTemplateParser.cs
- ServiceModelEnhancedConfigurationElementCollection.cs
- XmlnsCompatibleWithAttribute.cs
- MultipleCopiesCollection.cs
- SecurityException.cs
- BindingSourceDesigner.cs
- TileModeValidation.cs
- DBSchemaTable.cs
- ContextBase.cs
- PrinterSettings.cs
- ScriptReferenceBase.cs
- URL.cs
- InnerItemCollectionView.cs
- GridItemPattern.cs
- DocobjHost.cs
- SmtpNetworkElement.cs
- ToolStripSeparatorRenderEventArgs.cs
- FunctionMappingTranslator.cs
- SoapReflectionImporter.cs
- ImageFormatConverter.cs
- OdbcConnection.cs
- _HeaderInfo.cs
- ManagedWndProcTracker.cs
- DataRecord.cs
- BStrWrapper.cs
- CheckBox.cs
- ColorAnimationBase.cs
- JournalNavigationScope.cs
- DataSourceView.cs
- DescendantOverDescendantQuery.cs
- ArrayTypeMismatchException.cs
- IPipelineRuntime.cs
- NameNode.cs
- CompoundFileStorageReference.cs
- StorageMappingItemLoader.cs
- FreeFormPanel.cs
- Viewport3DVisual.cs
- AssemblySettingAttributes.cs
- ListenerUnsafeNativeMethods.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- ControlPaint.cs
- TypeBuilderInstantiation.cs
- LingerOption.cs
- ScriptBehaviorDescriptor.cs
- CellQuery.cs
- LogStream.cs
- Attributes.cs
- String.cs
- SchemaAttDef.cs
- OleDbMetaDataFactory.cs
- DataError.cs
- EntityTypeEmitter.cs
- XmlAttributes.cs
- ActivityExecutorSurrogate.cs
- FileDetails.cs
- SoapIgnoreAttribute.cs
- MetadataItemEmitter.cs
- DBSchemaTable.cs
- XmlValueConverter.cs
- WrappedOptions.cs
- QueryContinueDragEvent.cs
- SiteMapProvider.cs
- ToolBarButton.cs
- FixedElement.cs
- TransportSecurityBindingElement.cs
- DataBoundControl.cs