i have a weird label problem . If i introduce something like the code below, even though i create a label with the same attributes but different location , it only displays the first. If i comment the "a" section and leave the details for the b label, the b label is displayed correctly . What is wrong? Regards, Alexandru Badescu
a = new Label();
a.Name = listaS.ElementAt(i).nrSucursala;
a.Location = new Point(20, 3);
a.Text = listaS.ElementAt(i).nrSucursala + "";
this.panel1.Controls.Add(a);
b = new Label();
b.Name = listaS.ElementAt(i).nrSucursala;
开发者_如何学编程b.Location = new Point(20, 11);
b.Text = listaS.ElementAt(i).nrSucursala + "";
this.panel1.Controls.Add(b);
From what you provided as code snippet it is difficult to say what is wrong. Try narrowing down the problem. Start by the evident that should work and progressively enhance it with other code:
var a = new Label();
a.Name = "a name";
a.Location = new Point(20, 3);
a.Text = "a text";
this.panel1.Controls.Add(a);
var b = new Label();
b.Name = "b name";
b.Location = new Point(20, 11);
b.Text = "b text";
this.panel1.Controls.Add(b);
Notice how the a
and b
variables are locally declared.
It was the size.. but i don't understand why it worked for a label and not for 2 when i runned the code..
精彩评论