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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- D3DImage.cs
- OutOfMemoryException.cs
- PathTooLongException.cs
- TemplateBindingExpression.cs
- NativeMethods.cs
- BuiltInPermissionSets.cs
- EditingContext.cs
- RestClientProxyHandler.cs
- ManipulationLogic.cs
- JsonFormatGeneratorStatics.cs
- SQLConvert.cs
- _ScatterGatherBuffers.cs
- DisplayInformation.cs
- UpdateEventArgs.cs
- AsymmetricAlgorithm.cs
- XmlSchemaElement.cs
- IUnknownConstantAttribute.cs
- SslStream.cs
- Border.cs
- KerberosRequestorSecurityToken.cs
- Thickness.cs
- NativeObjectSecurity.cs
- AutoCompleteStringCollection.cs
- ItemsControl.cs
- KeySplineConverter.cs
- UnsafeNativeMethods.cs
- Config.cs
- cookiecollection.cs
- XmlSchemaComplexContentExtension.cs
- SqlUDTStorage.cs
- WebPartConnectionsDisconnectVerb.cs
- SafeNativeMethods.cs
- WSFederationHttpSecurity.cs
- DataBoundControl.cs
- RenderData.cs
- LicenseException.cs
- EncodingInfo.cs
- BaseAutoFormat.cs
- IntSecurity.cs
- Vertex.cs
- MessagePropertyAttribute.cs
- TreeViewEvent.cs
- AxDesigner.cs
- ReturnType.cs
- DecoderFallbackWithFailureFlag.cs
- ConnectionManagementElementCollection.cs
- Duration.cs
- ExpressionTable.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- BamlLocalizer.cs
- EmbeddedMailObjectCollectionEditor.cs
- ProfileSection.cs
- FieldToken.cs
- WebServiceFault.cs
- XmlTextAttribute.cs
- _FixedSizeReader.cs
- PersonalizationDictionary.cs
- ProviderConnectionPoint.cs
- CriticalHandle.cs
- XmlExpressionDumper.cs
- ConfigXmlCDataSection.cs
- DesignerVerb.cs
- QueryContinueDragEventArgs.cs
- DataViewSetting.cs
- SkipQueryOptionExpression.cs
- FormViewDeleteEventArgs.cs
- DbConnectionStringCommon.cs
- ObjectParameterCollection.cs
- StreamWriter.cs
- PropVariant.cs
- CatalogZone.cs
- OutputCacheModule.cs
- BaseProcessor.cs
- GacUtil.cs
- XmlSchemaGroup.cs
- RuntimeArgumentHandle.cs
- PropertyChangedEventManager.cs
- ComboBox.cs
- ContentValidator.cs
- TextBox.cs
- FileDataSourceCache.cs
- WeakEventTable.cs
- SocketStream.cs
- VolatileResourceManager.cs
- ApplicationSettingsBase.cs
- ChannelManagerBase.cs
- ConvertEvent.cs
- QueryReaderSettings.cs
- SynchronizedInputPattern.cs
- CallTemplateAction.cs
- CombinedHttpChannel.cs
- ReplyChannel.cs
- HostSecurityManager.cs
- XmlAutoDetectWriter.cs
- HtmlShim.cs
- DesignerOptionService.cs
- DBAsyncResult.cs
- HtmlInputFile.cs
- DetailsView.cs
- ListDictionaryInternal.cs