Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / TreeViewImageKeyConverter.cs / 1305376 / TreeViewImageKeyConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Collections.Specialized; ////// /// ImageIndexConverter is a class that can be used to convert /// image index values one data type to another. /// public class TreeViewImageKeyConverter : ImageKeyConverter { ////// /// 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(string) && (value == null)) { return SR.GetString(SR.toStringDefault); } else { string strValue = value as string; if (strValue != null && (strValue.Length == 0)) { return SR.GetString(SR.toStringDefault); } } 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 Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Collections.Specialized; ////// /// ImageIndexConverter is a class that can be used to convert /// image index values one data type to another. /// public class TreeViewImageKeyConverter : ImageKeyConverter { ////// /// 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(string) && (value == null)) { return SR.GetString(SR.toStringDefault); } else { string strValue = value as string; if (strValue != null && (strValue.Length == 0)) { return SR.GetString(SR.toStringDefault); } } 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
- TemplatedAdorner.cs
- Profiler.cs
- XmlArrayAttribute.cs
- WorkflowRuntimeElement.cs
- XmlDataSourceView.cs
- AbandonedMutexException.cs
- WebServiceEnumData.cs
- DataGridViewCellMouseEventArgs.cs
- ReachFixedPageSerializer.cs
- MasterPageBuildProvider.cs
- PowerModeChangedEventArgs.cs
- Package.cs
- IntPtr.cs
- RawKeyboardInputReport.cs
- TextTabProperties.cs
- ListBindingHelper.cs
- IsolationInterop.cs
- InputEventArgs.cs
- RoleGroupCollection.cs
- RunClient.cs
- RootBrowserWindowProxy.cs
- ListBindingHelper.cs
- DataGridViewCellCollection.cs
- DataGridViewEditingControlShowingEventArgs.cs
- AttributeQuery.cs
- DbModificationCommandTree.cs
- ControlPaint.cs
- EntityClientCacheKey.cs
- CreatingCookieEventArgs.cs
- WebPartTransformerAttribute.cs
- XmlSchemaValidationException.cs
- ToolStripOverflow.cs
- PassportAuthentication.cs
- CheckBoxFlatAdapter.cs
- Label.cs
- NonParentingControl.cs
- TimerElapsedEvenArgs.cs
- ServicePointManager.cs
- WorkflowApplicationCompletedException.cs
- SqlCharStream.cs
- GZipStream.cs
- IDispatchConstantAttribute.cs
- CommandEventArgs.cs
- StringPropertyBuilder.cs
- MediaPlayer.cs
- StringUtil.cs
- EdmConstants.cs
- BasicCellRelation.cs
- CaseStatement.cs
- EntityKeyElement.cs
- WebControlsSection.cs
- DataControlFieldCell.cs
- ToolStripOverflowButton.cs
- TraceSection.cs
- NavigateEvent.cs
- ValidatedControlConverter.cs
- BitmapEffectvisualstate.cs
- XmlDictionaryString.cs
- FillBehavior.cs
- SqlWorkflowInstanceStoreLock.cs
- DataTransferEventArgs.cs
- XNodeNavigator.cs
- StringStorage.cs
- WebPartConnectionsConfigureVerb.cs
- InitializerFacet.cs
- QueryParameter.cs
- Timer.cs
- XmlSchemaSubstitutionGroup.cs
- CryptoProvider.cs
- SmtpMail.cs
- XsdDateTime.cs
- FileDataSourceCache.cs
- OutputScopeManager.cs
- ImageAttributes.cs
- XmlnsCache.cs
- coordinator.cs
- XmlILTrace.cs
- FullTextLine.cs
- CodeGotoStatement.cs
- BinaryEditor.cs
- UnsafeMethods.cs
- LockRecoveryTask.cs
- MailFileEditor.cs
- ClosureBinding.cs
- HMAC.cs
- DataGridCellEditEndingEventArgs.cs
- CommandField.cs
- IntSecurity.cs
- TextWriterEngine.cs
- TreeWalker.cs
- Documentation.cs
- MessageSmuggler.cs
- MetadataSource.cs
- DoubleLink.cs
- PresentationSource.cs
- RuleCache.cs
- BooleanFunctions.cs
- ClientConfigurationHost.cs
- regiisutil.cs
- HttpCookie.cs