dimanche 1 octobre 2017

I'm using int parse same way as it is in the console application but doesn't work in winforms

I need some help because I can't seem to get to display the text label here. I am using Windows Form C# VS 2015. When I press enter the error is on barangay = int.Parse(lblDistrict.Text); uhm also, I am applying the same way console.readline is used but it seems that it doesn't work. Can somebody help me in the code? :) Thanks in advance

private void txtBarangay_KeyPress(object sender, KeyPressEventArgs e)
{

    int barangay = 0;
    barangay = int.Parse(lblDistrict.Text);

    if (e.KeyChar == (char)13)
    {
        if (barangay >= 1 && barangay <= 146)
        {
            lblDistrict.Text = "District 1";
        }
        else if (barangay >= 147 && barangay <= 267)
        {
            lblDistrict.Text = "District 2";
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire