示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            JPlacesEditForm editForm = new JPlacesEditForm();

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                jCustomTreeView1.FieldsValue["Name"]  = editForm.txtTitle.Text;
                jCustomTreeView1.FieldsValue["State"] = editForm.cmbState.SelectedIndex;
                jCustomTreeView1.DefaultCode          = 0;
                jCustomTreeView1.AutoIncrement        = true;
                if (jCustomTreeView1.TreeView.SelectedNode == null)
                {
                    jCustomTreeView1.FieldsValue["ParentCode"] = 0;
                }
                else
                {
                    jCustomTreeView1.FieldsValue["ParentCode"] = ((JCustomTreeNode)jCustomTreeView1.TreeView.SelectedNode.Tag).Code;
                }
                TreeNode treeNode = jCustomTreeView1.Insert();
                if (treeNode != null)
                {
                    jCustomTreeView1.TreeView.SelectedNode = treeNode;
                    jCustomTreeView1.Focus();
                }
            }
        }
示例#2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (jCustomTreeView1.TreeView.SelectedNode == null)
            {
                return;
            }

            JPlacesEditForm editForm = new JPlacesEditForm();

            editForm.txtTitle.Text          = jCustomTreeView1.FieldsValue["Name"].ToString();
            editForm.cmbState.SelectedIndex = Convert.ToInt32(jCustomTreeView1.FieldsValue["State"]);
            if (editForm.ShowDialog() == DialogResult.OK)
            {
                jCustomTreeView1.FieldsValue["Name"]  = editForm.txtTitle.Text;
                jCustomTreeView1.FieldsValue["State"] = editForm.cmbState.SelectedIndex;
                TreeNode treeNode = jCustomTreeView1.Update();
                if (treeNode != null)
                {
                    jCustomTreeView1.TreeView.SelectedNode.Text = treeNode.Tag.ToString();
                }
                jCustomTreeView1.Focus();
            }
        }