Code:
/ DotNET / DotNET / 8.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
- Hyperlink.cs
- WebPartConnectionsDisconnectVerb.cs
- WebPartConnectionsCancelEventArgs.cs
- RowParagraph.cs
- ProtocolsConfigurationHandler.cs
- MsmqIntegrationChannelFactory.cs
- GenericEnumConverter.cs
- HttpHeaderCollection.cs
- InputScopeAttribute.cs
- mansign.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- XmlQueryOutput.cs
- BlockUIContainer.cs
- DataProtection.cs
- ClaimTypeElementCollection.cs
- PolyQuadraticBezierSegment.cs
- SolidColorBrush.cs
- XmlDocument.cs
- ExecutionContext.cs
- UpdateTranslator.cs
- DependencyPropertyAttribute.cs
- ReadOnlyHierarchicalDataSource.cs
- ContractsBCL.cs
- SigningProgress.cs
- ChannelManager.cs
- EllipseGeometry.cs
- SQLMoneyStorage.cs
- PageHandlerFactory.cs
- RoutedEventArgs.cs
- StyleBamlRecordReader.cs
- BamlWriter.cs
- DiscoveryViaBehavior.cs
- MouseGesture.cs
- SecurityTokenRequirement.cs
- FormatConvertedBitmap.cs
- ClientCultureInfo.cs
- FormViewDeletedEventArgs.cs
- SHA1CryptoServiceProvider.cs
- PropertyMappingExceptionEventArgs.cs
- VoiceChangeEventArgs.cs
- ExpandedWrapper.cs
- FusionWrap.cs
- RequestQueryProcessor.cs
- CallbackException.cs
- ReferencedAssemblyResolver.cs
- ManagementOptions.cs
- WrapPanel.cs
- PermissionSetTriple.cs
- Point3DIndependentAnimationStorage.cs
- ContainerControl.cs
- loginstatus.cs
- COAUTHIDENTITY.cs
- XmlValidatingReaderImpl.cs
- RelationshipDetailsCollection.cs
- DelegatingTypeDescriptionProvider.cs
- StopStoryboard.cs
- Stack.cs
- TemplatePartAttribute.cs
- CodeExpressionCollection.cs
- BypassElement.cs
- PageThemeCodeDomTreeGenerator.cs
- InvokeHandlers.cs
- ButtonChrome.cs
- RequestUriProcessor.cs
- _TLSstream.cs
- CustomWebEventKey.cs
- Int16Storage.cs
- CheckBox.cs
- DynamicValidatorEventArgs.cs
- SpecialFolderEnumConverter.cs
- WebPageTraceListener.cs
- CategoryList.cs
- _HeaderInfoTable.cs
- CTreeGenerator.cs
- RefreshEventArgs.cs
- Itemizer.cs
- SQLUtility.cs
- ThreadSafeMessageFilterTable.cs
- QueryStringParameter.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- LinkedResource.cs
- MtomMessageEncoder.cs
- WebProxyScriptElement.cs
- ByteStreamMessageEncoder.cs
- SelectionPatternIdentifiers.cs
- BitArray.cs
- ComAwareEventInfo.cs
- BasicHttpSecurityElement.cs
- ToolStripButton.cs
- SafeNativeMethodsOther.cs
- FrameworkName.cs
- FactoryMaker.cs
- View.cs
- XmlIlGenerator.cs
- SqlUtils.cs
- ClientScriptManagerWrapper.cs
- BulletDecorator.cs
- ListDictionary.cs
- WeakReference.cs
- RijndaelCryptoServiceProvider.cs