Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / DesignBindingValueUIHandler.cs / 1 / DesignBindingValueUIHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Design { using System; using System.Collections; using System.Windows.Forms; using Microsoft.Win32; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing.Design; using System.Drawing; ////// /// /// internal class DesignBindingValueUIHandler : IDisposable { private Bitmap dataBitmap; internal Bitmap DataBitmap { get { if (dataBitmap == null) { dataBitmap = new Bitmap(typeof(DesignBindingValueUIHandler), "BoundProperty.bmp"); dataBitmap.MakeTransparent(); } return dataBitmap; } } internal void OnGetUIValueItem(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList){ if (context.Instance is Control) { Control control = (Control) context.Instance; foreach (Binding binding in control.DataBindings) { // Only add the binding if it is one of the data source types we recognize. Otherwise, our drop-down list won't show it as // an option, which is confusing. if ((binding.DataSource is IListSource || binding.DataSource is IList || binding.DataSource is Array) && binding.PropertyName.Equals(propDesc.Name)) { valueUIItemList.Add(new LocalUIItem(this, binding)); } } } } class LocalUIItem : PropertyValueUIItem { Binding binding; internal LocalUIItem(DesignBindingValueUIHandler handler, Binding binding) : base(handler.DataBitmap, new PropertyValueUIItemInvokeHandler(handler.OnPropertyValueUIItemInvoke), GetToolTip(binding)) { this.binding = binding; } internal Binding Binding { get { return binding; } } static string GetToolTip(Binding binding) { string name = ""; if (binding.DataSource is IComponent) { IComponent comp = (IComponent) binding.DataSource; if (comp.Site != null) { name = comp.Site.Name; } } if (name.Length == 0) { name = "(List)"; } name += " - " + binding.BindingMemberInfo.BindingMember; return name; } } private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem) { LocalUIItem localItem = (LocalUIItem) invokedItem; IServiceProvider sop = null; Control control = localItem.Binding.Control; if (control.Site != null) { sop = ( IServiceProvider ) control.Site.GetService(typeof( IServiceProvider )); } if (sop != null) { AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, sop, control.DataBindings); } } public void Dispose() { if (dataBitmap != null) { dataBitmap.Dispose(); } } } } // 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
- QueryContext.cs
- SoapInteropTypes.cs
- BaseServiceProvider.cs
- Inline.cs
- Version.cs
- SmtpLoginAuthenticationModule.cs
- FormClosedEvent.cs
- CheckBox.cs
- SponsorHelper.cs
- ContentType.cs
- SapiAttributeParser.cs
- AutomationPeer.cs
- HostedHttpTransportManager.cs
- Model3D.cs
- EncoderReplacementFallback.cs
- ParameterRefs.cs
- StatusBarItemAutomationPeer.cs
- assemblycache.cs
- _NegoStream.cs
- SAPIEngineTypes.cs
- SkinBuilder.cs
- SecurityCookieModeValidator.cs
- TagPrefixCollection.cs
- XsltInput.cs
- HwndAppCommandInputProvider.cs
- cookie.cs
- MD5.cs
- TraceRecord.cs
- StylusDownEventArgs.cs
- Scheduling.cs
- HttpServerVarsCollection.cs
- SqlException.cs
- MenuItemBinding.cs
- ConfigurationManagerHelper.cs
- UserControlParser.cs
- ExtendedPropertyDescriptor.cs
- __Filters.cs
- TagNameToTypeMapper.cs
- SemanticTag.cs
- HierarchicalDataBoundControl.cs
- SourceLocation.cs
- FastEncoder.cs
- XmlDictionaryWriter.cs
- ExpressionsCollectionConverter.cs
- CaseInsensitiveHashCodeProvider.cs
- ServiceCredentials.cs
- DateTimeOffset.cs
- ADMembershipProvider.cs
- NotFiniteNumberException.cs
- RowToParametersTransformer.cs
- StatusBarDrawItemEvent.cs
- LinkConverter.cs
- WindowsListView.cs
- CodeDelegateInvokeExpression.cs
- errorpatternmatcher.cs
- MenuItem.cs
- BufferedReadStream.cs
- ApplicationSettingsBase.cs
- safemediahandle.cs
- PathFigure.cs
- OverrideMode.cs
- RecordsAffectedEventArgs.cs
- ViewStateException.cs
- BindingEntityInfo.cs
- CellTreeNode.cs
- GeometryHitTestResult.cs
- NamedPipeActivation.cs
- UpdateProgress.cs
- ComponentResourceKey.cs
- SelectedDatesCollection.cs
- AppLevelCompilationSectionCache.cs
- CompareValidator.cs
- SafeNativeMethods.cs
- SortedList.cs
- RegexCharClass.cs
- GridViewDeletedEventArgs.cs
- NoneExcludedImageIndexConverter.cs
- LocalizableResourceBuilder.cs
- QueueAccessMode.cs
- ClrProviderManifest.cs
- AuthenticateEventArgs.cs
- IISMapPath.cs
- Pen.cs
- DirectoryInfo.cs
- precedingquery.cs
- XmlSerializationGeneratedCode.cs
- AddInStore.cs
- BasicBrowserDialog.cs
- GatewayDefinition.cs
- ElementHostPropertyMap.cs
- QueryOperationResponseOfT.cs
- QilLiteral.cs
- DataTableCollection.cs
- InvokerUtil.cs
- RegexCode.cs
- TypeDependencyAttribute.cs
- NameValueSectionHandler.cs
- RSAOAEPKeyExchangeFormatter.cs
- Opcode.cs
- TagPrefixInfo.cs