Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / listviewsubitemcollectioneditor.cs / 1 / listviewsubitemcollectioneditor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.ListViewSubItemCollectionEditor..ctor(System.Type)")] namespace System.Windows.Forms.Design { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.IO; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Windows.Forms; using System.Drawing; using System.Design; using System.Drawing.Design; using System.Windows.Forms.ComponentModel; ////// /// internal class ListViewSubItemCollectionEditor : CollectionEditor { private static int count = 0; ListViewItem.ListViewSubItem firstSubItem = null; ////// Provides an editor for an image collection. ////// /// public ListViewSubItemCollectionEditor(Type type) : base(type){ } ///Initializes a new instance of the ///class. /// /// // VSWhidbey 122909: Set the Name property in the item's properties. protected override object CreateInstance(Type type) { object instance = base.CreateInstance(type); // slap in a default site-like name if (instance is ListViewItem.ListViewSubItem) { ((ListViewItem.ListViewSubItem)instance).Name = SR.GetString(SR.ListViewSubItemBaseName) + count++; } return instance; } ///Creates an instance of the specified type in the collection. ////// /// Retrieves the display text for the given list sub item. /// protected override string GetDisplayText(object value) { string text; if (value == null) { return string.Empty; } PropertyDescriptor prop = TypeDescriptor.GetDefaultProperty(CollectionType); if (prop != null && prop.PropertyType == typeof(string)) { text = (string)prop.GetValue(value); if (text != null && text.Length > 0) { return text; } } text = TypeDescriptor.GetConverter(value).ConvertToString(value); if (text == null || text.Length == 0) { text = value.GetType().Name; } return text; } ///protected override object[] GetItems(object editValue) { // take the fist sub item out of the collection ListViewItem.ListViewSubItemCollection subItemsColl = (ListViewItem.ListViewSubItemCollection) editValue; // add all the other sub items object[] values = new object[subItemsColl.Count]; ((ICollection)subItemsColl).CopyTo(values, 0); if (values.Length > 0) { // save the first sub item firstSubItem = subItemsColl[0]; // now return the rest. // object[] subValues = new object[values.Length - 1]; Array.Copy(values, 1, subValues, 0, subValues.Length); values = subValues; } return values; } /// protected override object SetItems(object editValue, object[] value) { IList list = editValue as IList; list.Clear(); list.Add(firstSubItem); for (int i = 0; i < value.Length; i ++) { list.Add(value[i]); } return editValue; } } } // 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
- XmlValidatingReaderImpl.cs
- Keywords.cs
- ScriptIgnoreAttribute.cs
- SqlTypesSchemaImporter.cs
- MissingManifestResourceException.cs
- OrthographicCamera.cs
- SemanticValue.cs
- ProvidePropertyAttribute.cs
- EventSetterHandlerConverter.cs
- RecordBuilder.cs
- SHA256Managed.cs
- WinEventTracker.cs
- CommentEmitter.cs
- NativeActivityTransactionContext.cs
- WS2007HttpBindingElement.cs
- Permission.cs
- SQLString.cs
- TemplateParser.cs
- FaultHandlingFilter.cs
- ActivitySurrogateSelector.cs
- CatalogZoneDesigner.cs
- TextServicesDisplayAttribute.cs
- DateTimeOffsetConverter.cs
- SimpleHandlerBuildProvider.cs
- InheritanceService.cs
- FunctionQuery.cs
- StatusBarItem.cs
- ExtensionQuery.cs
- FileReservationCollection.cs
- SoapObjectInfo.cs
- GestureRecognizer.cs
- WasAdminWrapper.cs
- ApplicationGesture.cs
- SqlProcedureAttribute.cs
- SspiHelper.cs
- ApplicationSettingsBase.cs
- ItemTypeToolStripMenuItem.cs
- NamespaceDisplay.xaml.cs
- StringArrayConverter.cs
- CoTaskMemSafeHandle.cs
- PointF.cs
- OleDbCommandBuilder.cs
- TextContainerChangedEventArgs.cs
- ListBase.cs
- GeneralTransform3DGroup.cs
- unsafenativemethodsother.cs
- RoleGroup.cs
- DataErrorValidationRule.cs
- Timer.cs
- DBConnectionString.cs
- objectquery_tresulttype.cs
- SafeWaitHandle.cs
- EnvelopedPkcs7.cs
- RotateTransform3D.cs
- OdbcConnectionPoolProviderInfo.cs
- WinEventQueueItem.cs
- ToolStripItemRenderEventArgs.cs
- PageStatePersister.cs
- activationcontext.cs
- DataGridLinkButton.cs
- HtmlTableCell.cs
- CodeDirectiveCollection.cs
- HashMembershipCondition.cs
- Brush.cs
- ArgumentNullException.cs
- ApplicationGesture.cs
- Win32Exception.cs
- HtmlLiteralTextAdapter.cs
- FormsAuthenticationCredentials.cs
- SettingsProviderCollection.cs
- DbDataSourceEnumerator.cs
- ConsoleKeyInfo.cs
- followingquery.cs
- FormClosedEvent.cs
- DecimalFormatter.cs
- ErrorInfoXmlDocument.cs
- FixedHyperLink.cs
- ListBox.cs
- Main.cs
- RelationshipDetailsCollection.cs
- ContainerAction.cs
- Italic.cs
- DataControlPagerLinkButton.cs
- SqlClientMetaDataCollectionNames.cs
- ScrollProperties.cs
- x509store.cs
- DataServiceConfiguration.cs
- IdleTimeoutMonitor.cs
- DefinitionBase.cs
- HttpListenerElement.cs
- OutOfProcStateClientManager.cs
- OleDbMetaDataFactory.cs
- IProvider.cs
- SafeFileMappingHandle.cs
- SqlException.cs
- ObservableDictionary.cs
- cache.cs
- NameValueSectionHandler.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- SqlConnectionHelper.cs