コード例 #1
0
        /// <summary>
        /// Updates the data bindings for the form.
        /// </summary>
        private void UpdateDataBindings()
        {
            // set...
            _entityBindingManager = new EntityBindingManager(this.DataSource);

            // update the tag bindings..
            this.EntityBindingManager.BindControl(this);
        }
コード例 #2
0
ファイル: EntityMemberBox.cs プロジェクト: radtek/BootFX
        /// <summary>
        /// Updates the view.
        /// </summary>
        private void RefreshView()
        {
            if (this.DesignMode)
            {
                return;
            }

            try
            {
                // parent...
                if (ParentDataControl == null)
                {
                    throw new InvalidOperationException(string.Format("Control must be parented by an IEntityDataControl-implementing control."));
                }

                // binding?
                Type type = null;
                if (this.Binding != null)
                {
                    // get the type...
                    type = GetEditorType(this.Binding);

                    // get the name...
                    this.label.Text = GetEditorCaption(this.Binding) + ":";
                }
                else
                {
                    this.label.Text = string.Empty;
                }

                // reset...
                // TODO: make this more elegant so that we can reuse a control is appropriate...
                this.panel.Controls.Clear();

                // show...
                if (type != null)
                {
                    // create one...
                    IMemberEditor editor = (IMemberEditor)Activator.CreateInstance(type);
                    if (editor == null)
                    {
                        throw new InvalidOperationException("editor is null.");
                    }

                    // get the control...
                    Control editorControl = (Control)editor;

                    // get the bound member...
                    EntityMember boundMember = null;
                    if (this.Binding is EntityMemberBinding)
                    {
                        boundMember = ((EntityMemberBinding)this.Binding).Member;
                    }

                    // call out to the editor...
                    editor.Initializing(this, boundMember);
                    this.OnInitializeEditor(new MemberEditorEventArgs(editorControl, boundMember));
                    editor.Initialized();

                    // show...
                    editorControl.Dock = DockStyle.Fill;
                    this.panel.Controls.Add(editorControl);

                    // check...
                    if (editorControl.Height > this.Height)
                    {
                        this.Height = editorControl.Height;
                    }

                    // bind the control...
                    this.ParentDataControl.EntityBindingManager.CreateBinding(editorControl, EntityBindingManager.GetPropertyToBind(editorControl), (string)this.Tag);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Type not found for '{0}'.", this.Binding));
                }
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }