Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / ColumnCollection.cs / 1 / ColumnCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.Web.UI; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class DataGridColumnCollection : ICollection, IStateManager { private DataGrid owner; private ArrayList columns; private bool marked; ///Represents the collection of columns to be displayed in /// a ////// control. /// public DataGridColumnCollection(DataGrid owner, ArrayList columns) { this.owner = owner; this.columns = columns; } ///Initializes a new instance of ///class. /// [ Browsable(false) ] public int Count { get { return columns.Count; } } ///Gets the number of columns in the collection. This property is read-only. ////// [ Browsable(false) ] public bool IsReadOnly { get { return false; } } ///Gets a value that specifies whether items in the ///can be /// modified. This property is read-only. /// [ Browsable(false) ] public bool IsSynchronized { get { return false; } } ///Gets a value that indicates whether the ///is thread-safe. This property is read-only. /// [ Browsable(false) ] public Object SyncRoot { get { return this; } } ///Gets the object used to synchronize access to the collection. This property is read-only. ////// [ Browsable(false) ] public DataGridColumn this[int index] { get { return (DataGridColumn)columns[index]; } } ///Gets a ///at the specified index in the /// collection. /// public void Add(DataGridColumn column) { AddAt(-1, column); } ///Appends a ///to the collection. /// public void AddAt(int index, DataGridColumn column) { if (column == null) { throw new ArgumentNullException("column"); } if (index == -1) { columns.Add(column); } else { columns.Insert(index, column); } column.SetOwner(owner); if (marked) ((IStateManager)column).TrackViewState(); OnColumnsChanged(); } ///Inserts a ///to the collection /// at the specified index. /// public void Clear() { columns.Clear(); OnColumnsChanged(); } ///Empties the collection of all ///objects. /// public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array"); } for (IEnumerator e = this.GetEnumerator(); e.MoveNext();) array.SetValue(e.Current, index++); } ///Copies the contents of the entire collection into an ///appending at /// the specified index of the . /// public IEnumerator GetEnumerator() { return columns.GetEnumerator(); } ///Creates an enumerator for the ///used to iterate through the collection. /// public int IndexOf(DataGridColumn column) { if (column != null) { return columns.IndexOf(column); } return -1; } ///Returns the index of the first occurrence of a value in a ///. /// private void OnColumnsChanged() { if (owner != null) { owner.OnColumnsChanged(); } } ////// public void RemoveAt(int index) { if ((index >= 0) && (index < Count)) { columns.RemoveAt(index); OnColumnsChanged(); } else { throw new ArgumentOutOfRangeException("index"); } } ///Removes a ///from the collection at the specified /// index. /// public void Remove(DataGridColumn column) { int index = IndexOf(column); if (index >= 0) { RemoveAt(index); } } ///Removes the specified ///from the collection. /// /// Return true if tracking state changes. /// bool IStateManager.IsTrackingViewState { get { return marked; } } ////// /// Load previously saved state. /// void IStateManager.LoadViewState(object savedState) { if (savedState != null) { object[] columnsState = (object[])savedState; if (columnsState.Length == columns.Count) { for (int i = 0; i < columnsState.Length; i++) { if (columnsState[i] != null) { ((IStateManager)columns[i]).LoadViewState(columnsState[i]); } } } } } ////// /// Start tracking state changes. /// void IStateManager.TrackViewState() { marked = true; int columnCount = columns.Count; for (int i = 0; i < columnCount; i++) { ((IStateManager)columns[i]).TrackViewState(); } } ////// /// Return object containing state changes. /// object IStateManager.SaveViewState() { int columnCount = columns.Count; object[] columnsState = new object[columnCount]; bool savedState = false; for (int i = 0; i < columnCount; i++) { columnsState[i] = ((IStateManager)columns[i]).SaveViewState(); if (columnsState[i] != null) savedState = true; } return savedState ? columnsState : null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.Web.UI; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class DataGridColumnCollection : ICollection, IStateManager { private DataGrid owner; private ArrayList columns; private bool marked; ///Represents the collection of columns to be displayed in /// a ////// control. /// public DataGridColumnCollection(DataGrid owner, ArrayList columns) { this.owner = owner; this.columns = columns; } ///Initializes a new instance of ///class. /// [ Browsable(false) ] public int Count { get { return columns.Count; } } ///Gets the number of columns in the collection. This property is read-only. ////// [ Browsable(false) ] public bool IsReadOnly { get { return false; } } ///Gets a value that specifies whether items in the ///can be /// modified. This property is read-only. /// [ Browsable(false) ] public bool IsSynchronized { get { return false; } } ///Gets a value that indicates whether the ///is thread-safe. This property is read-only. /// [ Browsable(false) ] public Object SyncRoot { get { return this; } } ///Gets the object used to synchronize access to the collection. This property is read-only. ////// [ Browsable(false) ] public DataGridColumn this[int index] { get { return (DataGridColumn)columns[index]; } } ///Gets a ///at the specified index in the /// collection. /// public void Add(DataGridColumn column) { AddAt(-1, column); } ///Appends a ///to the collection. /// public void AddAt(int index, DataGridColumn column) { if (column == null) { throw new ArgumentNullException("column"); } if (index == -1) { columns.Add(column); } else { columns.Insert(index, column); } column.SetOwner(owner); if (marked) ((IStateManager)column).TrackViewState(); OnColumnsChanged(); } ///Inserts a ///to the collection /// at the specified index. /// public void Clear() { columns.Clear(); OnColumnsChanged(); } ///Empties the collection of all ///objects. /// public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array"); } for (IEnumerator e = this.GetEnumerator(); e.MoveNext();) array.SetValue(e.Current, index++); } ///Copies the contents of the entire collection into an ///appending at /// the specified index of the . /// public IEnumerator GetEnumerator() { return columns.GetEnumerator(); } ///Creates an enumerator for the ///used to iterate through the collection. /// public int IndexOf(DataGridColumn column) { if (column != null) { return columns.IndexOf(column); } return -1; } ///Returns the index of the first occurrence of a value in a ///. /// private void OnColumnsChanged() { if (owner != null) { owner.OnColumnsChanged(); } } ////// public void RemoveAt(int index) { if ((index >= 0) && (index < Count)) { columns.RemoveAt(index); OnColumnsChanged(); } else { throw new ArgumentOutOfRangeException("index"); } } ///Removes a ///from the collection at the specified /// index. /// public void Remove(DataGridColumn column) { int index = IndexOf(column); if (index >= 0) { RemoveAt(index); } } ///Removes the specified ///from the collection. /// /// Return true if tracking state changes. /// bool IStateManager.IsTrackingViewState { get { return marked; } } ////// /// Load previously saved state. /// void IStateManager.LoadViewState(object savedState) { if (savedState != null) { object[] columnsState = (object[])savedState; if (columnsState.Length == columns.Count) { for (int i = 0; i < columnsState.Length; i++) { if (columnsState[i] != null) { ((IStateManager)columns[i]).LoadViewState(columnsState[i]); } } } } } ////// /// Start tracking state changes. /// void IStateManager.TrackViewState() { marked = true; int columnCount = columns.Count; for (int i = 0; i < columnCount; i++) { ((IStateManager)columns[i]).TrackViewState(); } } ////// /// Return object containing state changes. /// object IStateManager.SaveViewState() { int columnCount = columns.Count; object[] columnsState = new object[columnCount]; bool savedState = false; for (int i = 0; i < columnCount; i++) { columnsState[i] = ((IStateManager)columns[i]).SaveViewState(); if (columnsState[i] != null) savedState = true; } return savedState ? columnsState : 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
- Hyperlink.cs
- ValidationSummary.cs
- QueryContinueDragEventArgs.cs
- EditCommandColumn.cs
- BinaryObjectWriter.cs
- EventLogEntryCollection.cs
- QuaternionRotation3D.cs
- NativeMethods.cs
- smtpconnection.cs
- DataGridViewRowEventArgs.cs
- XhtmlBasicPanelAdapter.cs
- OleDbParameter.cs
- DataGridColumnHeader.cs
- Pool.cs
- EntityTypeBase.cs
- MarshalDirectiveException.cs
- formatstringdialog.cs
- WinEventHandler.cs
- FunctionCommandText.cs
- NamespaceQuery.cs
- CodeConstructor.cs
- Convert.cs
- ConditionedDesigner.cs
- NamedObject.cs
- HasActivatableWorkflowEvent.cs
- AuthenticationModuleElement.cs
- _SafeNetHandles.cs
- Binding.cs
- DateTimeUtil.cs
- CallbackException.cs
- EncoderExceptionFallback.cs
- LayoutEvent.cs
- HTMLTagNameToTypeMapper.cs
- BorderGapMaskConverter.cs
- EdmComplexTypeAttribute.cs
- DataGridViewLayoutData.cs
- UriTemplate.cs
- PrintPreviewDialog.cs
- AncestorChangedEventArgs.cs
- BasicCellRelation.cs
- CompositeActivityTypeDescriptor.cs
- HtmlListAdapter.cs
- GeneralTransform3DTo2D.cs
- ParallelRangeManager.cs
- ResourcePermissionBaseEntry.cs
- PartManifestEntry.cs
- ScaleTransform3D.cs
- DesignBindingPicker.cs
- InternalPermissions.cs
- DynamicFilter.cs
- DataControlButton.cs
- RangeContentEnumerator.cs
- DynamicQueryableWrapper.cs
- ProtectedConfigurationProviderCollection.cs
- ProcessThread.cs
- SqlServices.cs
- DesignOnlyAttribute.cs
- GlobalEventManager.cs
- LockCookie.cs
- CodeRemoveEventStatement.cs
- UriTemplateVariablePathSegment.cs
- StrongNameKeyPair.cs
- MailSettingsSection.cs
- NullableFloatMinMaxAggregationOperator.cs
- PagesSection.cs
- WindowPattern.cs
- NativeMethods.cs
- UriTemplateCompoundPathSegment.cs
- SqlDataSourceFilteringEventArgs.cs
- PropVariant.cs
- Random.cs
- ApplicationDirectory.cs
- SystemGatewayIPAddressInformation.cs
- TreeWalker.cs
- SQLByteStorage.cs
- AnnotationHighlightLayer.cs
- RequiredArgumentAttribute.cs
- XPathSelfQuery.cs
- NotSupportedException.cs
- SqlWebEventProvider.cs
- DnsEndPoint.cs
- AliasGenerator.cs
- RegexEditorDialog.cs
- CapabilitiesState.cs
- LogicalTreeHelper.cs
- HoistedLocals.cs
- CodeParameterDeclarationExpression.cs
- SortDescription.cs
- CodeGroup.cs
- XhtmlBasicPageAdapter.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- EpmSourceTree.cs
- Point3DCollection.cs
- VisemeEventArgs.cs
- Documentation.cs
- LocalizableResourceBuilder.cs
- RectangleConverter.cs
- CutCopyPasteHelper.cs
- WorkflowServiceBehavior.cs
- SignatureToken.cs