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
- UriScheme.cs
- ScriptBehaviorDescriptor.cs
- KnownTypesProvider.cs
- IOException.cs
- HttpProfileGroupBase.cs
- Command.cs
- EditorPartChrome.cs
- WindowsSlider.cs
- PartManifestEntry.cs
- wmiprovider.cs
- DependencyPropertyAttribute.cs
- ToolStripDropDownClosingEventArgs.cs
- _NativeSSPI.cs
- CompilerCollection.cs
- XmlBinaryWriterSession.cs
- LogicalMethodInfo.cs
- ResourceDisplayNameAttribute.cs
- ListViewInsertEventArgs.cs
- DocumentSequence.cs
- RuleInfoComparer.cs
- ScriptingRoleServiceSection.cs
- ListBase.cs
- AmbientLight.cs
- XamlBrushSerializer.cs
- SettingsAttributeDictionary.cs
- ISFTagAndGuidCache.cs
- EventTask.cs
- InitialServerConnectionReader.cs
- CommonGetThemePartSize.cs
- DataServiceRequestOfT.cs
- FormViewInsertedEventArgs.cs
- BinaryUtilClasses.cs
- Win32.cs
- DataPagerFieldItem.cs
- WebPartsSection.cs
- ExpressionBindingCollection.cs
- Timer.cs
- CodeNamespaceCollection.cs
- EntryPointNotFoundException.cs
- ExpanderAutomationPeer.cs
- BitFlagsGenerator.cs
- DeleteMemberBinder.cs
- AbsoluteQuery.cs
- TransformCryptoHandle.cs
- ServiceOperationParameter.cs
- DataGridViewRowStateChangedEventArgs.cs
- ConnectionManagementElement.cs
- OleDbCommandBuilder.cs
- MostlySingletonList.cs
- DragEvent.cs
- SafeNativeMethodsOther.cs
- ToolboxDataAttribute.cs
- FontWeights.cs
- VirtualDirectoryMapping.cs
- StatusBar.cs
- TextMetrics.cs
- PersonalizationDictionary.cs
- NetworkInterface.cs
- ResourceDisplayNameAttribute.cs
- TreePrinter.cs
- PointCollection.cs
- BuildProvidersCompiler.cs
- StylusPointProperty.cs
- XmlWriterTraceListener.cs
- DynamicDocumentPaginator.cs
- TypeUtil.cs
- CellParaClient.cs
- RadioButtonStandardAdapter.cs
- Base64WriteStateInfo.cs
- WorkflowInstance.cs
- WorkflowEventArgs.cs
- FixedSOMPageConstructor.cs
- SHA256Managed.cs
- InfoCardBaseException.cs
- ServiceObjectContainer.cs
- PEFileEvidenceFactory.cs
- XmlHierarchyData.cs
- FamilyTypeface.cs
- CatalogPartChrome.cs
- InputDevice.cs
- CustomCategoryAttribute.cs
- Variant.cs
- UrlMapping.cs
- AdCreatedEventArgs.cs
- Pair.cs
- MultiPageTextView.cs
- AttachedPropertyInfo.cs
- SplineKeyFrames.cs
- DiagnosticTraceSource.cs
- ExceptionRoutedEventArgs.cs
- FileDataSourceCache.cs
- ReflectionServiceProvider.cs
- EventArgs.cs
- RouteItem.cs
- ComponentChangedEvent.cs
- DrawTreeNodeEventArgs.cs
- PointCollection.cs
- VariableAction.cs
- StylusSystemGestureEventArgs.cs
- HttpPostedFile.cs