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
- AnimationStorage.cs
- HttpClientCertificate.cs
- ParameterCollection.cs
- Vector3DCollection.cs
- TreeView.cs
- GridViewEditEventArgs.cs
- RegionInfo.cs
- ToolboxDataAttribute.cs
- GC.cs
- KeyConverter.cs
- SizeIndependentAnimationStorage.cs
- OutKeywords.cs
- DateTimeParse.cs
- XmlNamespaceDeclarationsAttribute.cs
- formatstringdialog.cs
- SQLDateTimeStorage.cs
- BamlLocalizer.cs
- LinkArea.cs
- ZipFileInfoCollection.cs
- DbCommandDefinition.cs
- XhtmlConformanceSection.cs
- WebPartCloseVerb.cs
- Scalars.cs
- TypefaceMap.cs
- elementinformation.cs
- CodeTypeReferenceExpression.cs
- CodeNamespaceImport.cs
- FileNotFoundException.cs
- SR.cs
- TextInfo.cs
- ExpanderAutomationPeer.cs
- IPHostEntry.cs
- Base64Decoder.cs
- WebPartDisplayMode.cs
- PersonalizationProviderHelper.cs
- PasswordDeriveBytes.cs
- RuntimeIdentifierPropertyAttribute.cs
- LinearKeyFrames.cs
- SaveFileDialog.cs
- TextEffect.cs
- BufferModeSettings.cs
- DateTime.cs
- Compiler.cs
- COAUTHINFO.cs
- DragStartedEventArgs.cs
- BooleanFacetDescriptionElement.cs
- LineSegment.cs
- DataSourceComponent.cs
- XPathNavigatorKeyComparer.cs
- InputLanguage.cs
- Stylesheet.cs
- SafeBitVector32.cs
- SmtpException.cs
- UInt32Converter.cs
- ObjectQueryProvider.cs
- ObjectViewFactory.cs
- SendMessageChannelCache.cs
- SoapAttributes.cs
- AnimationLayer.cs
- ObjectToModelValueConverter.cs
- _HeaderInfoTable.cs
- ListViewDeletedEventArgs.cs
- ThemeableAttribute.cs
- GroupQuery.cs
- SchemaEntity.cs
- LoadRetryHandler.cs
- PathSegment.cs
- ActivityExecutionContextCollection.cs
- BitmapImage.cs
- ThreadAttributes.cs
- DictionaryBase.cs
- FormattedText.cs
- DrawListViewItemEventArgs.cs
- StreamResourceInfo.cs
- LassoSelectionBehavior.cs
- PeerNameRecordCollection.cs
- Hash.cs
- FormClosedEvent.cs
- DPTypeDescriptorContext.cs
- TraceEventCache.cs
- LocalTransaction.cs
- _KerberosClient.cs
- TemplateBindingExpression.cs
- TextServicesLoader.cs
- ObservableCollection.cs
- CheckPair.cs
- StylusPointPropertyInfoDefaults.cs
- HuffModule.cs
- ConfigXmlComment.cs
- StatusBarAutomationPeer.cs
- DataServiceQuery.cs
- WebPartMenu.cs
- JournalNavigationScope.cs
- CellPartitioner.cs
- HttpConfigurationContext.cs
- GridViewSortEventArgs.cs
- Attributes.cs
- DataObjectMethodAttribute.cs
- SessionPageStatePersister.cs
- StorageRoot.cs