Exemplo n.º 1
0
        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 advancedPropDesc = new AdvancedBindingPropertyDescriptor();
                AdvancedBindingObject             advancedObject   = (AdvancedBindingObject)advancedPropDesc.GetValue(control.DataBindings);
                AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, sop, advancedObject);
            }
        }
Exemplo n.º 2
0
        /// <include file='doc\AdvancedBindingEditor.uex' path='docs/doc[@for="AdvancedBindingEditor.EditValue"]/*' />
        /// <devdoc>
        ///    <para>Edits the specified value using the specified provider
        ///       within the specified context.</para>
        /// </devdoc>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    if (advancedBindingPicker == null)
                    {
                        advancedBindingPicker = new AdvancedBindingPicker(context);
                    }

                    IComponentChangeService changeSvc = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService));
                    Control c = ((ControlBindingsCollection)context.Instance).Control;
                    if (changeSvc != null)
                    {
                        changeSvc.OnComponentChanging(c, TypeDescriptor.GetProperties(c)["DataBindings"]);
                    }

                    AdvancedBindingObject abo = (AdvancedBindingObject)value;
                    abo.Changed = false;
                    advancedBindingPicker.Value = abo;
                    edSvc.ShowDialog(advancedBindingPicker);
                    advancedBindingPicker.End();

                    if (abo.Changed)
                    {
                        // since the bindings may have changed, the properties listed in the properties window
                        // need to be refreshed
                        Debug.Assert(context.Instance is ControlBindingsCollection);
                        TypeDescriptor.Refresh(((ControlBindingsCollection)context.Instance).Control);
                        if (changeSvc != null)
                        {
                            changeSvc.OnComponentChanged(c, TypeDescriptor.GetProperties(c)["DataBindings"], null, null);
                        }
                    }
                }
            }

            return(value);
        }
 private void CheckBox1_CheckedChanged(object sender, EventArgs e)
 {
     // CONSIDER: make this nicer... this will reset the browsable attribute.
     Value = value;
 }