/// <summary> /// Añadir nuevo campo. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BttnAddField_Click(object sender, EventArgs e) { int indx; FieldsTypeSelect fts = new FieldsTypeSelect(); var result = fts.ShowDialog(); if (result == DialogResult.OK) { StackedPanel.SuspendLayout(); FieldPanel p = CreateField(fts.Type); StackedPanel.Controls.Add(p); if (FocusedControl != null) { indx = StackedPanel.Controls.IndexOf(FocusedControl); StackedPanel.Controls.SetChildIndex(p, indx + 1); } StackedPanel.ResumeLayout(); StackedPanel.ScrollControlIntoView(p); } }
/// <summary> /// Cambiar tipo de campo del campo seleccionado. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChangeField(object sender, EventArgs e) { int indx; FieldPanel prevField = ((sender as Button).Parent as Panel).Parent as FieldPanel; FieldsTypeSelect fts = new FieldsTypeSelect(); var result = fts.ShowDialog(); if (result == DialogResult.OK && prevField.FieldType.BName != fts.Type.BName) { StackedPanel.SuspendLayout(); indx = StackedPanel.Controls.IndexOf(prevField); FieldPanel p = CreateField(fts.Type, prevField.TBFieldName.Text); StackedPanel.Controls.RemoveAt(indx); StackedPanel.Controls.Add(p); StackedPanel.Controls.SetChildIndex(p, indx); StackedPanel.ResumeLayout(); } }