locked
Keep the array value to the label. RRS feed

  • Question

  • I have:

    an array (string[,] letters = new string[6, 5]),

    2 static ints: static int huidige_letter = 0; static int huidige_regel = 0;

    and 5 labels, l1, l2, l3, l4, l5.

    and I'm filling the array with only dots. When you hit a letter key then the first [0,0] should change to a letter. So what I did is:

    if (e.KeyChar >= 97 && e.KeyChar <= 122)
                    {

        l1.Text = letters[0, 0];
                        l2.Text = letters[0, 1];
                        l3.Text = letters[0, 2];
                        l4.Text = letters[0, 3];
                        l5.Text = letters[0, 4];                   

                        letters[huidige_regel, huidige_letter] = e.KeyChar.ToString().ToUpper();
                        huidige_letter++;

    }

    and a little bit more to show up what value the int's are. It's working fine, it replaces the original dot with the letter in capital. But when the labels are changing, the previous labels are changing back to a dot. So, when you hit A-P-P-E-L, the A is showing, the P also, but the A is changing back to a dot. The next P is showing, but the previous is changing. 

    How could I prevent the labels of changing back to a dot (value in the array letters)?


    • Edited by Donovan_DD Saturday, September 3, 2016 4:00 PM
    • Moved by DotNet Wang Monday, September 5, 2016 7:32 AM
    Saturday, September 3, 2016 3:59 PM

Answers

  • Hi Donovan_DD,

    >>"How could I prevent the labels of changing back to a dot (value in the array letters)?"

    It depend on how did you fill the array with only dots. Could you please provide this code?  It seems that the filling array with dots code had been executed multi times. I tested the code which you provided, it worked fine on my side.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, September 10, 2016 2:34 AM

All replies

  • Hi Donovan_DD,

    Since your problem is more related to windows form. I moved it to Windows Form for support.

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding.

    Best Regards,

    Wendy


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, September 5, 2016 7:31 AM
  • Hi Donovan_DD,

    >>"How could I prevent the labels of changing back to a dot (value in the array letters)?"

    It depend on how did you fill the array with only dots. Could you please provide this code?  It seems that the filling array with dots code had been executed multi times. I tested the code which you provided, it worked fine on my side.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, September 10, 2016 2:34 AM