Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / DataGridViewCellStyleConverter.cs / 1 / DataGridViewCellStyleConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using System.Runtime.Serialization.Formatters; using System.Runtime.Remoting; using System.Runtime.InteropServices; using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Globalization; using System.Reflection; ////// /// public class DataGridViewCellStyleConverter : TypeConverter { ////// /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ///Gets a value indicating whether this converter can /// convert an object to the given destination type using the context. ////// /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is DataGridViewCellStyle) { ConstructorInfo ctor = value.GetType().GetConstructor(new Type[0]); return new InstanceDescriptor(ctor, new object[0], false); } return base.ConvertTo(context, culture, value, destinationType); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using System.Runtime.Serialization.Formatters; using System.Runtime.Remoting; using System.Runtime.InteropServices; using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Globalization; using System.Reflection; ////// /// public class DataGridViewCellStyleConverter : TypeConverter { ////// /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ///Gets a value indicating whether this converter can /// convert an object to the given destination type using the context. ////// /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is DataGridViewCellStyle) { ConstructorInfo ctor = value.GetType().GetConstructor(new Type[0]); return new InstanceDescriptor(ctor, new object[0], false); } return base.ConvertTo(context, culture, value, destinationType); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SectionRecord.cs
- TextSelectionProcessor.cs
- ReadOnlyDataSource.cs
- UrlAuthFailedErrorFormatter.cs
- BindingMAnagerBase.cs
- Triplet.cs
- _NegoState.cs
- PersistenceContext.cs
- ContainerParagraph.cs
- FilterQuery.cs
- InternalEnumValidatorAttribute.cs
- DecoderReplacementFallback.cs
- TypeTypeConverter.cs
- InstanceLockException.cs
- ProtectedProviderSettings.cs
- WebSysDescriptionAttribute.cs
- SystemEvents.cs
- AccessibilityHelperForVista.cs
- ContextMenuAutomationPeer.cs
- CodeEntryPointMethod.cs
- ToolBar.cs
- VisualBrush.cs
- StylusPointPropertyInfoDefaults.cs
- DrawingVisual.cs
- SpellerError.cs
- DebugView.cs
- ChannelManager.cs
- DbExpressionBuilder.cs
- validationstate.cs
- HtmlControl.cs
- SafeViewOfFileHandle.cs
- SystemPens.cs
- XmlAttributeOverrides.cs
- RotateTransform3D.cs
- GridLengthConverter.cs
- Rule.cs
- BinHexEncoder.cs
- XDeferredAxisSource.cs
- ConfigurationStrings.cs
- BaseTemplateParser.cs
- ConvertEvent.cs
- CodeSnippetStatement.cs
- HwndHostAutomationPeer.cs
- SiteOfOriginContainer.cs
- SafeLocalMemHandle.cs
- OdbcReferenceCollection.cs
- PeerToPeerException.cs
- AccessKeyManager.cs
- WebPageTraceListener.cs
- WebConfigurationHostFileChange.cs
- ComponentEditorPage.cs
- ViewValidator.cs
- ParameterCollection.cs
- RealizationDrawingContextWalker.cs
- IChannel.cs
- RegistryExceptionHelper.cs
- ReadWriteObjectLock.cs
- PointValueSerializer.cs
- ConstraintManager.cs
- OpCopier.cs
- MachineKeySection.cs
- SrgsOneOf.cs
- SharedConnectionInfo.cs
- SoapProtocolImporter.cs
- HttpListenerRequest.cs
- SwitchLevelAttribute.cs
- OleDbCommandBuilder.cs
- Trigger.cs
- SqlConnection.cs
- SafeLocalMemHandle.cs
- EndOfStreamException.cs
- baseaxisquery.cs
- ParameterEditorUserControl.cs
- InitializerFacet.cs
- PolyBezierSegmentFigureLogic.cs
- HwndSourceParameters.cs
- Message.cs
- Floater.cs
- NameValuePair.cs
- WebResourceAttribute.cs
- RouteValueExpressionBuilder.cs
- Button.cs
- SocketCache.cs
- Timeline.cs
- LocatorBase.cs
- ForeignConstraint.cs
- PermissionSetEnumerator.cs
- XsltOutput.cs
- AlternateViewCollection.cs
- ProcessInfo.cs
- XPathItem.cs
- DocumentGridContextMenu.cs
- GC.cs
- TableLayoutRowStyleCollection.cs
- OracleString.cs
- StorageEntitySetMapping.cs
- ParameterCollection.cs
- ImageInfo.cs
- PartitionResolver.cs
- WsdlBuildProvider.cs