/// <summary> /// Reset the form values /// </summary> public void ResetForm() { selectedParentVariable = null; selectedParentTreeNode = null; foreach (Control field in this.Controls) { if (field is TextBox) { ((TextBox)field).Clear(); } else if (field is ComboBox) { ((ComboBox)field).SelectedIndex = 0; } } }
/// <summary> /// Populate form with values from an existing tree node /// </summary> /// <param name="node"></param> private void populateForm(StatTreeNode node) { if (node == null) { return; } // Disable editing if node selected parent level is greater than 3 if (node.Level > 3) { formPanel.Enabled = false; return; } else { formPanel.Enabled = true; } // Get variable from selected node Variable sv = (Variable)node.Tag; // Set selected parent nodes selectedParentTreeNode = node; selectedParentVariable = sv; // Set level of NEW node tbVarLevel.Text = (node.Level + 2).ToString(); // Get the name of the selected node tbParentVariable.Text = sv.getNameAtLevel(node.Level + 1); // Populate text and comboboxes cbKretstyper.SelectedValue = sv.fk_kretstyper; cbTimeUnit.SelectedValue = sv.time_unit; cbUnit.SelectedValue = sv.unit; chkbShowUnit.Checked = sv.showunit; }