Code:
/ FX-1434 / FX-1434 / 1.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
- HtmlInputRadioButton.cs
- TableHeaderCell.cs
- FileReservationCollection.cs
- DoubleLinkListEnumerator.cs
- ScrollPatternIdentifiers.cs
- XmlSchemaGroupRef.cs
- StyleXamlTreeBuilder.cs
- TabControlEvent.cs
- DependencyObject.cs
- HostedElements.cs
- ControlValuePropertyAttribute.cs
- HttpCacheParams.cs
- FormsAuthenticationUserCollection.cs
- CheckoutException.cs
- QilExpression.cs
- UrlMappingsModule.cs
- MatrixAnimationBase.cs
- Attachment.cs
- SQLSingle.cs
- ToolStripSeparator.cs
- UInt16Converter.cs
- Scene3D.cs
- NativeActivityAbortContext.cs
- DWriteFactory.cs
- StructuredTypeEmitter.cs
- TCPListener.cs
- DataTableTypeConverter.cs
- FontInfo.cs
- UrlAuthFailedErrorFormatter.cs
- basecomparevalidator.cs
- Win32SafeHandles.cs
- WmpBitmapDecoder.cs
- QueryableFilterRepeater.cs
- SemanticBasicElement.cs
- OleDbEnumerator.cs
- OleDbTransaction.cs
- NeutralResourcesLanguageAttribute.cs
- PageThemeBuildProvider.cs
- ImageFormat.cs
- XmlTextWriter.cs
- CompilationUtil.cs
- WorkflowTransactionService.cs
- ADMembershipProvider.cs
- NavigatorOutput.cs
- IPAddressCollection.cs
- CrossAppDomainChannel.cs
- ConfigXmlElement.cs
- ModelPerspective.cs
- SubstitutionResponseElement.cs
- ValuePattern.cs
- XmlNamespaceManager.cs
- HttpCachePolicyElement.cs
- IsolatedStorageFilePermission.cs
- ApplicationServiceManager.cs
- Inline.cs
- TreeViewAutomationPeer.cs
- ParameterCollection.cs
- ParameterToken.cs
- SQLConvert.cs
- OrderToken.cs
- StringStorage.cs
- FormsAuthenticationUser.cs
- BuildProvidersCompiler.cs
- PermissionRequestEvidence.cs
- ObjectListComponentEditor.cs
- DirectoryObjectSecurity.cs
- DataContractAttribute.cs
- ApplicationFileParser.cs
- MethodBuilder.cs
- shaperfactory.cs
- LiteralControl.cs
- RequestSecurityToken.cs
- OracleConnection.cs
- TypeDescriptorFilterService.cs
- DisplayNameAttribute.cs
- baseshape.cs
- FixedTextPointer.cs
- InputLangChangeEvent.cs
- ImportCatalogPart.cs
- SafeTimerHandle.cs
- ProfileEventArgs.cs
- SystemWebExtensionsSectionGroup.cs
- BulletedListDesigner.cs
- UTF7Encoding.cs
- NamespaceList.cs
- LinkUtilities.cs
- AxHost.cs
- TextSelectionHighlightLayer.cs
- XmlDocumentType.cs
- TheQuery.cs
- MouseBinding.cs
- ListSourceHelper.cs
- HeaderedItemsControl.cs
- CollectionViewGroupRoot.cs
- Utils.cs
- WizardPanelChangingEventArgs.cs
- XmlSigningNodeWriter.cs
- SoundPlayer.cs
- PromptEventArgs.cs
- DictionaryMarkupSerializer.cs