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
- SmiEventSink.cs
- ValidationErrorCollection.cs
- IndexingContentUnit.cs
- WaitHandle.cs
- ClientFormsIdentity.cs
- BamlResourceSerializer.cs
- TopClause.cs
- MSG.cs
- ChunkedMemoryStream.cs
- FileFormatException.cs
- TemplateBuilder.cs
- Int32CollectionConverter.cs
- RankException.cs
- XmlEventCache.cs
- BatchParser.cs
- StorageScalarPropertyMapping.cs
- FatalException.cs
- SspiSecurityTokenProvider.cs
- SplayTreeNode.cs
- CodeTypeMemberCollection.cs
- XsdBuildProvider.cs
- WebServiceHandler.cs
- OrderedEnumerableRowCollection.cs
- WindowPatternIdentifiers.cs
- ExpressionVisitor.cs
- ExtenderControl.cs
- GridLengthConverter.cs
- EntityContainerAssociationSetEnd.cs
- _IPv6Address.cs
- Vector3DAnimationUsingKeyFrames.cs
- MultipleFilterMatchesException.cs
- BitmapEffectDrawing.cs
- SettingsPropertyValueCollection.cs
- Column.cs
- DataException.cs
- UnionCodeGroup.cs
- XPathAncestorQuery.cs
- StateItem.cs
- AnnotationResource.cs
- AsyncCompletedEventArgs.cs
- ByteStreamGeometryContext.cs
- RegexGroup.cs
- GridPattern.cs
- RTLAwareMessageBox.cs
- DataGridCommandEventArgs.cs
- FileUtil.cs
- NullRuntimeConfig.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- ReadonlyMessageFilter.cs
- HwndProxyElementProvider.cs
- OfTypeExpression.cs
- entityreference_tresulttype.cs
- ClientBuildManager.cs
- XPathScanner.cs
- DataGridCellsPresenter.cs
- ConstraintConverter.cs
- XmlValidatingReaderImpl.cs
- CustomTrackingQuery.cs
- FixedSOMContainer.cs
- DataGridViewComboBoxColumn.cs
- CommonRemoteMemoryBlock.cs
- SaveCardRequest.cs
- UIElement3D.cs
- ZipIOLocalFileHeader.cs
- MetaForeignKeyColumn.cs
- SqlUserDefinedTypeAttribute.cs
- TextInfo.cs
- DataGridViewCellParsingEventArgs.cs
- RijndaelManaged.cs
- TimerTable.cs
- MemberAccessException.cs
- DoubleKeyFrameCollection.cs
- ByteStream.cs
- XamlFilter.cs
- CompilerInfo.cs
- UIElement.cs
- DockPanel.cs
- VisualStyleElement.cs
- KeyInstance.cs
- ProvidersHelper.cs
- RC2CryptoServiceProvider.cs
- LicenseException.cs
- InfoCardProofToken.cs
- DataBindEngine.cs
- TimeSpanValidator.cs
- ColumnCollection.cs
- EntitySet.cs
- OutputScopeManager.cs
- COAUTHIDENTITY.cs
- CompositionAdorner.cs
- BaseTemplateBuildProvider.cs
- CalendarDesigner.cs
- WpfKnownMember.cs
- isolationinterop.cs
- BindingElementExtensionElement.cs
- DeobfuscatingStream.cs
- ProtectedConfigurationSection.cs
- OracleParameterBinding.cs
- GenerateTemporaryTargetAssembly.cs
- Group.cs