Click here to Skip to main content
14,775,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Dear developers !

I am a student and beginner in C#.
I want to add data from textbox into list and then retrieve all list data into single lable in list form
example

if user type 1 in textbox the vale store in list and user free to type second value 2 and the all data show in lable.text

e,g
Number
1
2
3
and so on


my code is
List<string> saveData1 = new List<string>();

            saveData1.Add(Name_TextBox.Text);

           MessageBox.Show(""+saveData1);
           for (int i = 0; i > 10; i++)
           {
               label3.Text = saveData1[i];
           }


and then store this data in database in different rows.
thaks

What I have tried:

I have a lot of search on google and try also this code


<pre>List<string> saveData1 = new List<string>();

             saveData1.Add(Name_TextBox.Text);

            MessageBox.Show(""+saveData1);
            for (int i = 0; i > 10; i++)
            {
                label3.Text = saveData1[i];
            }
Posted
Updated 15-May-20 0:36am

1 solution

You need to learn how to use events to capture data as the user is typing, since you have no control over how fast or slow they will enter the data. See How to: Raise and Consume Events | Microsoft Docs[^].
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900