Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / ColumnHeaderConverter.cs / 1 / ColumnHeaderConverter.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.Drawing; using System.Diagnostics; using System.Globalization; using System.Reflection; ////// /// public class ColumnHeaderConverter : ExpandableObjectConverter { ////// /// 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 ColumnHeader) { ColumnHeader col = (ColumnHeader) value; ConstructorInfo ctor; Type t = TypeDescriptor.GetReflectionType(value); InstanceDescriptor id = null; if (col.ImageIndex != -1) { ctor = t.GetConstructor(new Type[]{typeof(int)}); if (ctor != null) { id = new InstanceDescriptor(ctor, new object[]{col.ImageIndex}, false); } } if (id == null && !String.IsNullOrEmpty(col.ImageKey)) { ctor = t.GetConstructor(new Type[]{typeof(string)}); if (ctor != null) { id = new InstanceDescriptor(ctor, new object[]{col.ImageKey}, false); } } if (id == null) { ctor = t.GetConstructor(new Type[0]); if (ctor != null) { return new InstanceDescriptor(ctor, new object[0], false); } else { throw new ArgumentException(SR.GetString(SR.NoDefaultConstructor, t.FullName)); } } return id; } 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DbDataReader.cs
- ColorAnimationBase.cs
- AndCondition.cs
- SafeHandles.cs
- GuidelineSet.cs
- FixedSOMTextRun.cs
- ButtonPopupAdapter.cs
- IndexOutOfRangeException.cs
- ExpressionNode.cs
- CanExecuteRoutedEventArgs.cs
- NotificationContext.cs
- DataGridState.cs
- SessionMode.cs
- FileSystemInfo.cs
- EnumValAlphaComparer.cs
- SpinWait.cs
- DropShadowBitmapEffect.cs
- TypeConverterValueSerializer.cs
- XmlParserContext.cs
- OleDbEnumerator.cs
- OutputCacheProfileCollection.cs
- ZoneButton.cs
- _KerberosClient.cs
- QueryCursorEventArgs.cs
- PropertyCondition.cs
- OutputCacheSettingsSection.cs
- HeaderedItemsControl.cs
- FileLogRecordStream.cs
- Monitor.cs
- RewritingValidator.cs
- DBDataPermissionAttribute.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- ObjectIDGenerator.cs
- _HelperAsyncResults.cs
- BindingManagerDataErrorEventArgs.cs
- MetadataPropertyCollection.cs
- Wow64ConfigurationLoader.cs
- COM2PropertyPageUITypeConverter.cs
- HtmlControl.cs
- HiddenField.cs
- RSAPKCS1SignatureDeformatter.cs
- LinkClickEvent.cs
- MarkupExtensionParser.cs
- DSASignatureFormatter.cs
- SqlNotificationEventArgs.cs
- columnmapkeybuilder.cs
- StaticExtension.cs
- ToolStripItemEventArgs.cs
- ChildrenQuery.cs
- OAVariantLib.cs
- RegexStringValidator.cs
- DataGridViewRowsRemovedEventArgs.cs
- SecurityUtils.cs
- VisualTarget.cs
- coordinatorfactory.cs
- DataViewSetting.cs
- StreamingContext.cs
- SpnegoTokenProvider.cs
- WindowPatternIdentifiers.cs
- ToolTip.cs
- XPathSingletonIterator.cs
- CodeEntryPointMethod.cs
- ContainerUIElement3D.cs
- ParsedAttributeCollection.cs
- BinaryFormatterWriter.cs
- WindowsFormsHostPropertyMap.cs
- NamespaceDisplay.xaml.cs
- CommentAction.cs
- Binding.cs
- BufferedReceiveManager.cs
- ConfigurationStrings.cs
- ComponentDesigner.cs
- StylusPointPropertyInfoDefaults.cs
- CodeRegionDirective.cs
- CapabilitiesUse.cs
- Authorization.cs
- NameValueConfigurationCollection.cs
- StylusLogic.cs
- LocalFileSettingsProvider.cs
- SqlLiftIndependentRowExpressions.cs
- FrameAutomationPeer.cs
- DiscoveryInnerClientAdhocCD1.cs
- DataBinding.cs
- PanelStyle.cs
- RepeaterDataBoundAdapter.cs
- OdbcConnection.cs
- PartialTrustVisibleAssemblyCollection.cs
- ScrollData.cs
- NoResizeHandleGlyph.cs
- BufferedMessageWriter.cs
- Image.cs
- InfoCardRSACryptoProvider.cs
- RtType.cs
- GradientSpreadMethodValidation.cs
- ClientSettingsStore.cs
- TextParaClient.cs
- Vector.cs
- SrgsNameValueTag.cs
- WebServiceAttribute.cs
- EnumUnknown.cs