Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ColumnHeaderCollectionEditor.cs / 1 / ColumnHeaderCollectionEditor.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
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;
using System.Diagnostics.CodeAnalysis;
///
///
///
/// Provides an editor for an image collection.
///
internal class ColumnHeaderCollectionEditor : CollectionEditor {
///
///
/// Initializes a new instance of the class.
///
//Called through reflection
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public ColumnHeaderCollectionEditor(Type type) : base(type){
}
///
///
/// Gets the help topic to display for the dialog help button or pressing F1. Override to
/// display a different help topic.
///
protected override string HelpTopic {
get {
return "net.ComponentModel.ColumnHeaderCollectionEditor";
}
}
///
///
///
/// Sets
/// the specified collection to have the specified array of items.
///
///
protected override object SetItems(object editValue, object[] value) {
if (editValue != null) {
Array oldValue = (Array)GetItems(editValue);
bool valueSame = (oldValue.Length == value.Length);
// We look to see if the value implements IList, and if it does,
// we set through that.
//
Debug.Assert(editValue is System.Collections.IList, "editValue is not an IList");
System.Windows.Forms.ListView.ColumnHeaderCollection list = editValue as System.Windows.Forms.ListView.ColumnHeaderCollection;
if (editValue != null) {
list.Clear();
System.Windows.Forms.ColumnHeader[] colHeaders = new System.Windows.Forms.ColumnHeader[value.Length];
Array.Copy(value, 0, colHeaders, 0, value.Length);
list.AddRange( colHeaders );
}
}
return editValue;
}
///
///
///
/// Removes the item from listview column header collection
///
///
internal override void OnItemRemoving(object item) {
ListView listview = this.Context.Instance as ListView;
if (listview == null) {
return;
}
System.Windows.Forms.ColumnHeader column = item as System.Windows.Forms.ColumnHeader;
if (column != null) {
IComponentChangeService cs = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
PropertyDescriptor itemsProp = null;
if (cs != null) {
itemsProp = TypeDescriptor.GetProperties(this.Context.Instance)["Columns"];
cs.OnComponentChanging(this.Context.Instance, itemsProp);
}
listview.Columns.Remove( column );
if (cs != null && itemsProp != null) {
cs.OnComponentChanged(this.Context.Instance, itemsProp, null, null);
}
}
}
}
}
// 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
- LinkedList.cs
- InternalTypeHelper.cs
- SqlReferenceCollection.cs
- KeyConstraint.cs
- _NtlmClient.cs
- HostProtectionException.cs
- WebServicesSection.cs
- TdsParserStateObject.cs
- PreparingEnlistment.cs
- Lookup.cs
- DependencyPropertyKey.cs
- ToolboxDataAttribute.cs
- AsyncResult.cs
- FixedTextSelectionProcessor.cs
- _StreamFramer.cs
- DomainConstraint.cs
- FontNamesConverter.cs
- Int16KeyFrameCollection.cs
- Group.cs
- SettingsProviderCollection.cs
- SafeHandles.cs
- Rotation3DKeyFrameCollection.cs
- GlobalizationAssembly.cs
- ByteArrayHelperWithString.cs
- UpDownEvent.cs
- IISUnsafeMethods.cs
- SiteMapSection.cs
- HitTestParameters3D.cs
- JpegBitmapEncoder.cs
- FlowLayout.cs
- ScaleTransform.cs
- TreeNode.cs
- ThrowHelper.cs
- ChangePassword.cs
- GetReadStreamResult.cs
- ToolStripSeparatorRenderEventArgs.cs
- FormatConvertedBitmap.cs
- DbMetaDataFactory.cs
- RegionInfo.cs
- FormViewActionList.cs
- TemplateNameScope.cs
- MenuAdapter.cs
- LoginName.cs
- TypeElement.cs
- ToolboxItemCollection.cs
- DataGridAutoFormat.cs
- RsaKeyIdentifierClause.cs
- MarkupExtensionReturnTypeAttribute.cs
- SecurityProtocolCorrelationState.cs
- XmlDataContract.cs
- FilterQuery.cs
- SafeNativeMethodsMilCoreApi.cs
- CodeIterationStatement.cs
- RootBrowserWindowProxy.cs
- NavigatorOutput.cs
- PropertyTabAttribute.cs
- PanelDesigner.cs
- SqlNotificationEventArgs.cs
- XamlReaderHelper.cs
- WindowsStartMenu.cs
- SQLRoleProvider.cs
- HexParser.cs
- VirtualPath.cs
- BitmapCodecInfoInternal.cs
- Rotation3DAnimation.cs
- DbBuffer.cs
- InputLanguageCollection.cs
- SupportingTokenSpecification.cs
- CodeIdentifier.cs
- unsafeIndexingFilterStream.cs
- HostingEnvironmentSection.cs
- Brush.cs
- AccessViolationException.cs
- XslCompiledTransform.cs
- TableProviderWrapper.cs
- FactoryGenerator.cs
- CompositeControl.cs
- TextFormatter.cs
- ValuePatternIdentifiers.cs
- TextFormatterImp.cs
- LinqDataSourceSelectEventArgs.cs
- FormClosedEvent.cs
- DataServiceQueryProvider.cs
- WinFormsSecurity.cs
- ExtensionQuery.cs
- BitFlagsGenerator.cs
- TextSelectionHighlightLayer.cs
- GroupBoxAutomationPeer.cs
- RenderingBiasValidation.cs
- GraphicsPathIterator.cs
- WindowsTitleBar.cs
- Stack.cs
- RoleService.cs
- LogicalTreeHelper.cs
- TextTreeExtractElementUndoUnit.cs
- CommandBinding.cs
- TemplateColumn.cs
- BaseHashHelper.cs
- Dispatcher.cs
- HttpListenerResponse.cs