Estoy haciendo una aplicación en Visual Studio 2017, en C#, quisiera saber como puedo mandar el valor de la variable
public static DialogResult BandaOption(string title, string promText, ref string value, int tipo)
{
Form frm = new Form();
Label label = new Label();
System.Windows.Forms.ComboBox combo = new System.Windows.Forms.ComboBox();
Button buttonOK = new Button();
Button buttonCancel = new Button();
frm.Text = title;
label.Text = promText;
combo.Text = value;
combo.Items.Add("Banda 1");
combo.Items.Add("Banda 2");
buttonOK.Text = "Aceptar";
buttonCancel.Text = "Cancelar";
buttonOK.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.AutoSize = true;
combo.Anchor = combo.Anchor | AnchorStyles.Right;
buttonOK.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
frm.ClientSize = new Size(396, 107);
frm.Controls.AddRange(new Control[] { label, combo, buttonOK, buttonCancel });
frm.ClientSize = new Size(Math.Max(300, label.Right + 10), frm.ClientSize.Height);
frm.FormBorderStyle = FormBorderStyle.FixedDialog;
frm.StartPosition = FormStartPosition.CenterScreen;
frm.MinimizeBox = false;
frm.MaximizeBox = false;
frm.AcceptButton = buttonOK;
frm.CancelButton = buttonCancel;
DialogResult dialog = frm.ShowDialog();
value = Convert.ToString(combo.SelectedItem); //--> el valor de esta variable
return dialog;
}
a otro método dentro del mismo windows forms, para poder guardar unos datos. Ya lo he intentado con otros códigos, pero no me funciona