I need to converge a ComboBox to which I call cmbmes
. The reality is that it does not work with Convert.ToInt32()
or with Int.Parse()
. The error that gives me in specific is System.FormatException
.
What I want to achieve is that when I select an Item (Number) of the ComboBox, it tells me in a TextBox the Month.
The code is this:
private void Form1_Load(object sender, EventArgs e)
{
//Numero de Meses del Año
for (int i = 1; i <= 12; i++)
{
cmbmes.Items.Add(i);
}
//Para seleccionar el Mes
int numero;
numero = int.Parse(cmbmes.Text);
if (numero == 1)
{
txtmes.Text = "Enero";
}
else if (numero == 2)
{
txtmes.Text = "Febrero";
}
}
If you know another method, I would really appreciate it.