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
- BitmapEffectState.cs
- TickBar.cs
- AttributeQuery.cs
- HyperLinkColumn.cs
- MappingSource.cs
- AspNetSynchronizationContext.cs
- DecimalAnimation.cs
- CursorConverter.cs
- ServiceOperationWrapper.cs
- WebResourceUtil.cs
- FocusWithinProperty.cs
- InlineObject.cs
- WindowsScrollBar.cs
- RuntimeArgumentHandle.cs
- StaticContext.cs
- RelationalExpressions.cs
- DispatcherHooks.cs
- SrgsGrammarCompiler.cs
- remotingproxy.cs
- DropSourceBehavior.cs
- RegexReplacement.cs
- HwndSource.cs
- PropertyChangedEventArgs.cs
- SecUtil.cs
- AssertFilter.cs
- TemplateLookupAction.cs
- FrameDimension.cs
- ConfigXmlText.cs
- FormsAuthenticationModule.cs
- ErrorEventArgs.cs
- ResXDataNode.cs
- Utils.cs
- AdvancedBindingEditor.cs
- MaxValueConverter.cs
- CodeDomLoader.cs
- SafeEventLogReadHandle.cs
- DefaultEventAttribute.cs
- PathStreamGeometryContext.cs
- Binding.cs
- ValidatorCompatibilityHelper.cs
- AsyncResult.cs
- UriTemplateVariableQueryValue.cs
- TextEndOfParagraph.cs
- AssemblyResolver.cs
- TcpStreams.cs
- IncrementalReadDecoders.cs
- AddInIpcChannel.cs
- WmiInstallComponent.cs
- CurrentChangingEventManager.cs
- QilBinary.cs
- DiscreteKeyFrames.cs
- CryptoApi.cs
- InstalledFontCollection.cs
- ControlDesigner.cs
- WindowsIdentity.cs
- PointF.cs
- AttachedProperty.cs
- wmiprovider.cs
- Label.cs
- SQLSingle.cs
- MobileErrorInfo.cs
- PropertyChangeTracker.cs
- CompositeDataBoundControl.cs
- validation.cs
- HierarchicalDataTemplate.cs
- JsonWriter.cs
- CodeExpressionCollection.cs
- InputElement.cs
- TraceContextRecord.cs
- ImageAttributes.cs
- SqlNodeAnnotations.cs
- IPPacketInformation.cs
- ResourceProviderFactory.cs
- KoreanLunisolarCalendar.cs
- UInt64.cs
- SystemNetworkInterface.cs
- PixelFormatConverter.cs
- Convert.cs
- WindowsToolbarAsMenu.cs
- CreateUserWizardStep.cs
- FigureParagraph.cs
- MeshGeometry3D.cs
- TypeElementCollection.cs
- ISFClipboardData.cs
- DataGridSortCommandEventArgs.cs
- RoutedCommand.cs
- ProtocolReflector.cs
- ReferentialConstraint.cs
- PropertyPathWorker.cs
- BooleanFunctions.cs
- PropertyPathWorker.cs
- SQLBinaryStorage.cs
- InstanceDataCollectionCollection.cs
- ReflectionHelper.cs
- MatrixStack.cs
- ScrollBar.cs
- Soap.cs
- FieldToken.cs
- StrokeSerializer.cs
- DesignerAutoFormatCollection.cs