Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / RelatedPropertyManager.cs / 1 / RelatedPropertyManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using Microsoft.Win32; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.ComponentModel; using System.Collections; internal class RelatedPropertyManager : PropertyManager { BindingManagerBase parentManager; string dataField; PropertyDescriptor fieldInfo; [ SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors") // If the constructor does not set the dataSource // it would be a breaking change. ] internal RelatedPropertyManager(BindingManagerBase parentManager, string dataField) : base(GetCurrentOrNull(parentManager), dataField) { Bind(parentManager, dataField); } private void Bind(BindingManagerBase parentManager, string dataField) { Debug.Assert(parentManager != null, "How could this be a null parentManager."); this.parentManager = parentManager; this.dataField = dataField; this.fieldInfo = parentManager.GetItemProperties().Find(dataField, true); if (fieldInfo == null) throw new ArgumentException(SR.GetString(SR.RelatedListManagerChild, dataField)); // this.finalType = fieldInfo.PropertyType; parentManager.CurrentItemChanged += new EventHandler(ParentManager_CurrentItemChanged); Refresh(); } internal override string GetListName() { string name = GetListName(new ArrayList()); if (name.Length > 0) { return name; } return base.GetListName(); } protected internal override string GetListName(ArrayList listAccessors) { listAccessors.Insert(0, fieldInfo); return parentManager.GetListName(listAccessors); } internal override PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors) { PropertyDescriptor[] accessors; if (listAccessors != null && listAccessors.Length > 0) { accessors = new PropertyDescriptor[listAccessors.Length + 1]; listAccessors.CopyTo(accessors, 1); } else { accessors = new PropertyDescriptor[1]; } // Set this accessor (add to the beginning) accessors[0] = this.fieldInfo; // Get props return parentManager.GetItemProperties(accessors); } private void ParentManager_CurrentItemChanged(object sender, EventArgs e) { Refresh(); } private void Refresh() { EndCurrentEdit(); SetDataSource(GetCurrentOrNull(parentManager)); OnCurrentChanged(EventArgs.Empty); } internal override Type BindType { get { return fieldInfo.PropertyType; } } public override object Current { get { return (this.DataSource != null) ? fieldInfo.GetValue(this.DataSource) : null; } } static private object GetCurrentOrNull(BindingManagerBase parentManager) { bool anyCurrent = (parentManager.Position >= 0 && parentManager.Position < parentManager.Count); return anyCurrent ? parentManager.Current : 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
- ExpressionVisitor.cs
- DynamicDataResources.Designer.cs
- WebBrowserContainer.cs
- ClassImporter.cs
- DocumentPaginator.cs
- PixelFormatConverter.cs
- XmlSchemaImport.cs
- RpcCryptoRequest.cs
- UnsettableComboBox.cs
- FormCollection.cs
- SwitchAttribute.cs
- ProxyAttribute.cs
- PreProcessInputEventArgs.cs
- IUnknownConstantAttribute.cs
- ZipIOExtraFieldPaddingElement.cs
- SchemaImporter.cs
- TimeSpanFormat.cs
- ProcessModelInfo.cs
- WebSysDefaultValueAttribute.cs
- RuntimeHandles.cs
- WebScriptEndpointElement.cs
- AspCompat.cs
- Missing.cs
- CodeGenerationManager.cs
- QueuePathDialog.cs
- CultureInfo.cs
- WSHttpBindingBaseElement.cs
- HttpCapabilitiesBase.cs
- LineBreakRecord.cs
- InstanceCollisionException.cs
- UIElement3D.cs
- WebPartCatalogCloseVerb.cs
- GridViewCommandEventArgs.cs
- QueueSurrogate.cs
- TextWriterTraceListener.cs
- TableRowCollection.cs
- InvalidOperationException.cs
- WindowInteractionStateTracker.cs
- CodeMethodInvokeExpression.cs
- ScrollItemPatternIdentifiers.cs
- AccessorTable.cs
- IsolatedStorageFileStream.cs
- XhtmlConformanceSection.cs
- HelpInfo.cs
- WindowsRegion.cs
- XmlObjectSerializerReadContextComplex.cs
- NativeObjectSecurity.cs
- BitmapVisualManager.cs
- HitTestParameters.cs
- PassportAuthentication.cs
- Shape.cs
- DropAnimation.xaml.cs
- EventToken.cs
- Expander.cs
- Identity.cs
- ControlCodeDomSerializer.cs
- HelpHtmlBuilder.cs
- FloatSumAggregationOperator.cs
- FixedPage.cs
- ReferenceSchema.cs
- ArglessEventHandlerProxy.cs
- DataGridViewCellCancelEventArgs.cs
- Size.cs
- BamlWriter.cs
- PrintPageEvent.cs
- TTSVoice.cs
- SetIterators.cs
- SoapExtension.cs
- AdornerDecorator.cs
- DateTimeSerializationSection.cs
- CloudCollection.cs
- securitycriticaldata.cs
- DigestTraceRecordHelper.cs
- OleCmdHelper.cs
- SafeBitVector32.cs
- SingleResultAttribute.cs
- ICspAsymmetricAlgorithm.cs
- PersonalizationStateInfo.cs
- SqlStream.cs
- DebugView.cs
- DragDrop.cs
- TableParaClient.cs
- TrackingValidationObjectDictionary.cs
- Privilege.cs
- EncryptedPackageFilter.cs
- FolderLevelBuildProviderCollection.cs
- XmlSchemaSimpleTypeUnion.cs
- PrinterResolution.cs
- WebHttpDispatchOperationSelectorData.cs
- WmlImageAdapter.cs
- SpanIndex.cs
- _UncName.cs
- EntityCollection.cs
- TextTreeText.cs
- UriTemplateTrieNode.cs
- PathSegmentCollection.cs
- ContourSegment.cs
- NotifyParentPropertyAttribute.cs
- CachedTypeface.cs
- VariableValue.cs