I'm creating an application, where for each Char in a txt file (where some text is written), a label containing one char letter from the txt is created and written. In the txt file, "Hello" is written, and only the H appear
Here's my actual code :
string test = System.IO.File.ReadAllText(@"../../../../../Texte/Test.txt");
int x = 20;
int y = 20;
int i = 10;
foreach (char ch in test) {
Label newlabel = new Label();
newlabel.Location = new System.Drawing.Point(x + i, y);
newlabel.Text = ch.ToString();
panel1.Controls.Add(newlabel);
i += 15;
}
You should set AutoSize property of your label to TRUE. Without setting this property the first label covers the rest, so you can see only the first one. Try the following:
foreach (char ch in test) {
Label newlabel = new Label();
newlabel.Location = new System.Drawing.Point(x + i, y);
newlabel.Text = ch.ToString();
newlabel.AutoSize = true;
panel1.Controls.Add(newlabel);
i += 15;
}