Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / Util / NumberEdit.cs / 1 / NumberEdit.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- // NumberEdit.cs // // 3/18/99: [....]: created // namespace System.Web.UI.Design.Util { using System.ComponentModel; using System.Design; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.Runtime.Serialization.Formatters; using System.Windows.Forms; ////// /// Provides an edit control that only accepts numbers with addition /// restrictions such as whether negatives and decimals are allowed /// ///[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] internal sealed class NumberEdit : TextBox { private bool allowNegative = true; private bool allowDecimal = true; /// /// /// Controls whether the edit control allows negative values /// public bool AllowDecimal { get { return allowDecimal; } set { allowDecimal = value; } } ////// /// Controls whether the edit control allows negative values /// public bool AllowNegative { get { return allowNegative; } set { allowNegative = value; } } ////// /// Override of wndProc to listen to WM_CHAR and filter out invalid /// key strokes. Valid keystrokes are: /// 0...9, /// '.' (if fractions allowed), /// '-' (if negative allowed), /// BKSP. /// A beep is generated for invalid keystrokes /// protected override void WndProc(ref Message m) { if (m.Msg == NativeMethods.WM_CHAR) { char ch = (char)m.WParam; if (!(((ch >= '0') && (ch <= '9')) || (NumberFormatInfo.CurrentInfo.NumberDecimalSeparator.Contains(ch.ToString(CultureInfo.CurrentCulture)) && allowDecimal) || (NumberFormatInfo.CurrentInfo.NegativeSign.Contains(ch.ToString(CultureInfo.CurrentCulture)) && allowNegative) || (ch == (char)8))) { System.Console.Beep(); return; } } base.WndProc(ref m); } } } // 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
- LookupNode.cs
- GridProviderWrapper.cs
- CultureTable.cs
- EntityDataSourceContextCreatedEventArgs.cs
- UserPersonalizationStateInfo.cs
- ButtonRenderer.cs
- ListBoxItemWrapperAutomationPeer.cs
- TargetConverter.cs
- InstanceStoreQueryResult.cs
- MetadataException.cs
- NameValuePermission.cs
- WizardSideBarListControlItem.cs
- RoutingService.cs
- SingleAnimation.cs
- SecurityResources.cs
- DetailsViewDeleteEventArgs.cs
- EmptyControlCollection.cs
- MSG.cs
- FontFamilyValueSerializer.cs
- X509Certificate2.cs
- FunctionNode.cs
- UIAgentAsyncEndRequest.cs
- ObjectToken.cs
- TransactionTable.cs
- SqlUtil.cs
- OrCondition.cs
- WebPartCatalogAddVerb.cs
- IncrementalHitTester.cs
- DatasetMethodGenerator.cs
- LayoutEditorPart.cs
- OleDbParameter.cs
- TableLayoutPanelCellPosition.cs
- XmlBinaryReader.cs
- MultiDataTrigger.cs
- BindingExpression.cs
- ThreadPool.cs
- IgnoreFileBuildProvider.cs
- SqlInternalConnectionTds.cs
- CaseInsensitiveComparer.cs
- ReflectionHelper.cs
- ProxyFragment.cs
- URL.cs
- _AcceptOverlappedAsyncResult.cs
- Registry.cs
- SessionPageStateSection.cs
- TableColumn.cs
- XmlWrappingReader.cs
- DescendantBaseQuery.cs
- WebException.cs
- XmlSchemaProviderAttribute.cs
- SchemaCollectionPreprocessor.cs
- ConfigXmlComment.cs
- ZipPackage.cs
- AutomationElement.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- AttributeCollection.cs
- InvalidEnumArgumentException.cs
- RuleCache.cs
- SchemaMerger.cs
- Utils.cs
- PageSetupDialog.cs
- CommandID.cs
- PropertyBuilder.cs
- SoapProcessingBehavior.cs
- AnnotationStore.cs
- QilBinary.cs
- ButtonBaseAdapter.cs
- GradientStop.cs
- StaticDataManager.cs
- RecipientInfo.cs
- CachedFontFamily.cs
- TraceUtility.cs
- PanelContainerDesigner.cs
- DatePickerDateValidationErrorEventArgs.cs
- BasicViewGenerator.cs
- DynamicValidatorEventArgs.cs
- RoutingUtilities.cs
- ExtenderControl.cs
- ByteStreamGeometryContext.cs
- PolyLineSegment.cs
- FrameworkElementFactory.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- DataSourceHelper.cs
- WindowProviderWrapper.cs
- ContextMenu.cs
- ProcessProtocolHandler.cs
- NameValueConfigurationElement.cs
- SR.cs
- BindingCollection.cs
- EventWaitHandleSecurity.cs
- DynamicResourceExtension.cs
- CommandConverter.cs
- EventKeyword.cs
- NonVisualControlAttribute.cs
- WrapPanel.cs
- Object.cs
- StreamInfo.cs
- TraceListeners.cs
- TraceContext.cs
- CriticalFinalizerObject.cs