public override void DataBindControl(IDesignerHost designerHost, Control control) { DataBinding runtimeDataBinding = ((IDataBindingsAccessor)control).DataBindings["Text"]; if (runtimeDataBinding != null) { PropertyInfo property = control.GetType().GetProperty("Text"); if ((property != null) && (property.PropertyType == typeof(string))) { DesignTimeDataBinding binding2 = new DesignTimeDataBinding(runtimeDataBinding); string str = string.Empty; if (!binding2.IsCustom) { try { str = DataBinder.Eval(((IDataItemContainer)control.NamingContainer).DataItem, binding2.Field, binding2.Format); } catch { } } if ((str == null) || (str.Length == 0)) { str = System.Design.SR.GetString("Sample_Databound_Text"); } property.SetValue(control, str, null); } } }
public override void DataBindControl(IDesignerHost designerHost, Control control) { DataBinding runtimeDataBinding = ((IDataBindingsAccessor) control).DataBindings["Text"]; if (runtimeDataBinding != null) { PropertyInfo property = control.GetType().GetProperty("Text"); if ((property != null) && (property.PropertyType == typeof(string))) { DesignTimeDataBinding binding2 = new DesignTimeDataBinding(runtimeDataBinding); string str = string.Empty; if (!binding2.IsCustom) { try { str = DataBinder.Eval(((IDataItemContainer) control.NamingContainer).DataItem, binding2.Field, binding2.Format); } catch { } } if ((str == null) || (str.Length == 0)) { str = System.Design.SR.GetString("Sample_Databound_Text"); } property.SetValue(control, str, null); } } }
private void SaveCurrentDataBinding() { DesignTimeDataBinding binding = null; if (this._fieldBindingRadio.Checked) { if (this._fieldCombo.SelectedIndex > 0) { string text = this._fieldCombo.Text; string format = this.SaveFormat(); binding = new DesignTimeDataBinding(this._currentNode.PropertyDescriptor, text, format, this._twoWayBindingCheckBox.Checked); } } else { string expression = this._exprTextBox.Text.Trim(); if (expression.Length != 0) { binding = new DesignTimeDataBinding(this._currentNode.PropertyDescriptor, expression); } } if (binding == null) { this._currentNode.BindingMode = BindingMode.NotSet; this._bindings.Remove(this._currentNode.PropertyDescriptor.Name); } else { if (this._fieldBindingRadio.Checked) { if (this._twoWayBindingCheckBox.Checked && this._twoWayBindingCheckBox.Visible) { this._currentNode.BindingMode = BindingMode.TwoWay; } else { this._currentNode.BindingMode = BindingMode.OneWay; } } else if (binding.IsTwoWayBound) { this._currentNode.BindingMode = BindingMode.TwoWay; } else { this._currentNode.BindingMode = BindingMode.OneWay; } this._bindings[this._currentNode.PropertyDescriptor.Name] = binding; } this._currentDataBindingDirty = false; this._bindingsDirty = true; }
private void OnRefreshSchemaLinkLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (this._currentDataBindingDirty) { this.SaveCurrentDataBinding(); } IDesigner namingContainerDesigner = null; IDesignerHost service = (IDesignerHost) this.Control.Site.GetService(typeof(IDesignerHost)); if (service != null) { ControlDesigner designer2 = service.GetDesigner(this.Control) as ControlDesigner; if (designer2 != null) { namingContainerDesigner = this.GetNamingContainerDesigner(designer2); } } if (namingContainerDesigner != null) { IDataBindingSchemaProvider provider = namingContainerDesigner as IDataBindingSchemaProvider; if (provider != null) { provider.RefreshSchema(false); } } this.LoadFields(); if (this._currentNode != null) { this._currentDataBinding = (DesignTimeDataBinding) this._bindings[this._currentNode.PropertyDescriptor.Name]; } this.LoadCurrentDataBinding(); }
private void OnBindablePropsTreeAfterSelect(object sender, TreeViewEventArgs e) { if (this._currentDataBindingDirty) { this.SaveCurrentDataBinding(); } this._currentDataBinding = null; this._currentNode = (BindablePropertyNode) this._bindablePropsTree.SelectedNode; if (this._currentNode != null) { this._currentDataBinding = (DesignTimeDataBinding) this._bindings[this._currentNode.PropertyDescriptor.Name]; } this.LoadCurrentDataBinding(); }