dynamically create a label and assign text to it

fguihen

Junior Contributor
Joined
Nov 10, 2003
Messages
248
Location
Eire
i am trying to place a label on a GDI circle, and move it along the screen on the circle. the circle is a graphical representation of a person. here is how i create a label for each person:

Code:
lab = new Label[People.Count];
			foreach(Person p in People)
			{
				p.People = this.People;
				int sad = this.People.IndexOf(p);
				//labels[People.IndexOf(p)] = new Label();
				lab[People.IndexOf(p)] = new Label();
				
			}



when i update the circles position, i draw the label like this:

Code:
foreach(Person p in People)
			{
                                p.update();
				p.DrawToScreen(f.Graphics);
//				Label label = (Label)labels[People.IndexOf(p)-1];
//				label.Location = new System.Drawing.Point((int)p.position.Xval,(int)p.position.Yval);
//				label.Text = p.idNum.ToString();
				//p.UpdatePos();
				Label label = (Label)lab[People.IndexOf(p)];
				label.Location = new System.Drawing.Point((int)p.position.Xval,(int)p.position.Yval);
				float size = label.Font.Size;
				label.Text = p.idNum.ToString();
				label.Text = "test";
				label.Show();
				label.Refresh();
			}
			this.Invalidate();

my problem is that the label never shows up on screen. any suggestions?
 
Back
Top