Beispiel #1
0
        /// <summary>
        /// Event handler that sets the new value for the value column
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ValuePushed(object sender, NodeControlValueEventArgs e)
        {
            if (e.Node != null && e.Node.Tag != null)
            {
                GrtListNode node = e.Node.Tag as GrtListNode;

                if (node != null)
                {
                    if (sender == columnEnabledFkNodeControl)
                    {
                        bool isFK = (CheckState)e.Value == CheckState.Checked;
                        if (((FKConstraintColumnsListWrapper)grtList).set_column_is_fk(node.NodeId, isFK) && isFK)
                        {
                            // Sart editing the column only if it is enabled as FK column.
                            targetColumnNodeControl.Parent.SelectedNode = e.Node;
                            targetColumnNodeControl.BeginEdit();
                        }
                    }
                    else if (sender == nameNodeControl)
                    {
                        String value = e.Value as String;
                        if (value != null)
                        {
                            grtList.set_field(node.NodeId, (int)FKConstraintColumnsListWrapper.FKConstraintColumnsListColumns.Column, e.Value as String);
                        }
                    }
                    else if (sender == targetColumnNodeControl)
                    {
                        String value = e.Value as String;
                        if (value != null)
                        {
                            grtList.set_field(node.NodeId, (int)FKConstraintColumnsListWrapper.FKConstraintColumnsListColumns.RefColumn, e.Value as String);

                            // Setting a target column implicitly enables this columns a FK column.
                            ((FKConstraintColumnsListWrapper)grtList).set_column_is_fk(node.NodeId, true);
                        }
                    }

                    RefreshModel();
                }
            }
        }
        void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
            {
                Control c = sender as Control;
                if (c != null)
                {
                    if (c.Tag == nameNodeControl)
                    {
                        // Remember current index
                        int selIndex = 0;
                        if (this.TreeView.SelectedNode != null)
                        {
                            selIndex = this.TreeView.SelectedNode.Index;
                        }
                        ComboBox t     = c as ComboBox;
                        string   value = "";
                        if (t != null)
                        {
                            value = t.Text;
                        }

                        lengthNodeControl.EndEdit(true);

                        // Try to select previous index again
                        if (selIndex < this.TreeView.Root.Children.Count && value.Length > 0)
                        {
                            this.TreeView.SelectedNode = this.TreeView.Root.Children[selIndex];

                            // automatically go to the next row if this is the last "real" row
                            if (this.TreeView.SelectedNode != null &&
                                this.TreeView.SelectedNode.NextNode != null &&
                                this.TreeView.SelectedNode.NextNode.NextNode == null)
                            {
                                this.TreeView.SelectedNode =
                                    this.TreeView.SelectedNode.NextNode;

                                nameNodeControl.BeginEdit();
                            }
                        }

                        e.Handled = true;
                    }
                }
            }
        }
        void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
            {
                Control c = sender as Control;
                if (c != null)
                {
                    if (c.Tag == nameNodeControl)
                    {
                        // Remember current index
                        int selIndex = 0;
                        if (TreeView.SelectedNode != null)
                        {
                            selIndex = TreeView.SelectedNode.Index;
                        }
                        TextBox t     = c as TextBox;
                        string  value = "";
                        if (t != null)
                        {
                            value = t.Text;
                        }

                        nameNodeControl.EndEdit(true);

                        // Try to select previous index again
                        if (selIndex < TreeView.Root.Children.Count && value.Length > 0)
                        {
                            TreeView.SelectedNode = TreeView.Root.Children[selIndex];

                            targetNodeControl.BeginEdit();
                        }
                        e.Handled = true;
                    }
                    else if (c.Tag == targetNodeControl)
                    {
                        // Remember current index
                        int selIndex = 0;
                        if (TreeView.SelectedNode != null)
                        {
                            selIndex = TreeView.SelectedNode.Index;
                        }
                        ComboBox t     = c as ComboBox;
                        string   value = "";
                        if (t != null)
                        {
                            value = t.Text;
                        }

                        targetNodeControl.EndEdit(true);

                        // Try to select previous fk again
                        if (selIndex < TreeView.Root.Children.Count && value.Length > 0)
                        {
                            TreeView.SelectedNode = TreeView.Root.Children[selIndex];
                        }

                        columnEnabledFkNodeControl.Parent.Focus();
                        //columnEnabledFkNodeControl.Parent.SelectedNode = columnEnabledFkNodeControl.Parent.Root;

                        e.Handled = true;
                    }
                }
            }
        }
Beispiel #4
0
        void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                // notify cancel editing placeholder
                if (TreeView.SelectedNode != null)
                {
                    grtList.set_field(new NodeIdWrapper(TreeView.SelectedNode.Index), 0, 0);
                }
                RefreshModel();
            }
            else if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
            {
                Control c = sender as Control;
                if (c != null)
                {
                    if (c.Tag == nameNodeControl)
                    {
                        // Remember current index
                        int selIndex = 0;
                        if (TreeView.SelectedNode != null)
                        {
                            selIndex = TreeView.SelectedNode.Index;
                        }
                        TextBox t     = c as TextBox;
                        string  value = "";
                        if (t != null)
                        {
                            value = t.Text;
                        }

                        nameNodeControl.EndEdit(true);

                        // Try to select previous index again
                        if (selIndex < TreeView.Root.Children.Count && value.Length > 0)
                        {
                            TreeView.SelectedNode = TreeView.Root.Children[selIndex];

                            //datatypeNodeControl.BeginEdit();
                            datatypeComboBoxNodeControl.BeginEdit();
                        }
                        else
                        {
                            if (TreeView.SelectedNode != null)
                            {
                                // notify cancel editing placeholder
                                grtList.set_field(new NodeIdWrapper(selIndex), 0, 0);
                                RefreshModel();
                            }
                        }
                        e.Handled = true;
                    }
                    else if (c.Tag == datatypeComboBoxNodeControl)
                    {
                        // Remember current index
                        int selIndex = 0;
                        if (TreeView.SelectedNode != null)
                        {
                            selIndex = TreeView.SelectedNode.Index;
                        }
                        ComboBox t     = c as ComboBox;
                        string   value = "";
                        if (t != null)
                        {
                            value = t.Text;
                        }

                        datatypeComboBoxNodeControl.EndEdit(true);

                        // Try to select previous index again
                        if (selIndex < TreeView.Root.Children.Count && value.Length > 0)
                        {
                            TreeView.SelectedNode = TreeView.Root.Children[selIndex];

                            // automatically go to the next row if this is the last "real" row
                            if (TreeView.SelectedNode != null &&
                                TreeView.SelectedNode.NextNode != null &&
                                TreeView.SelectedNode.NextNode.NextNode == null)
                            {
                                TreeView.SelectedNode =
                                    TreeView.SelectedNode.NextNode;

                                nameNodeControl.BeginEdit();
                            }
                            else
                            {
                                if (TreeView.SelectedNode != null)
                                {
                                    // notify cancel editing placeholder
                                    grtList.set_field(new NodeIdWrapper(selIndex), 0, 0);
                                    RefreshModel();
                                }
                            }
                        }
                        else
                        {
                            if (TreeView.SelectedNode != null)
                            {
                                // notify cancel editing placeholder
                                grtList.set_field(new NodeIdWrapper(TreeView.SelectedNode.Index), 0, 0);
                                RefreshModel();
                            }
                        }

                        e.Handled = true;
                    }
                    else if (c.Tag == defaultNodeControl)
                    {
                        defaultNodeControl.EndEdit(true);
                        e.Handled = true;
                    }
                }
            }
        }