fguihen Posted April 19, 2005 Posted April 19, 2005 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: 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: 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? Quote
Administrators PlausiblyDamp Posted April 19, 2005 Administrators Posted April 19, 2005 You will also need to add the label to the form's controls collection. lab[People.IndexOf(p)] = new Label(); this.Controls.Add(lab[People.IndexOf(p)]); Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
IngisKahn Posted April 19, 2005 Posted April 19, 2005 It might be a good idea to just use DrawString instead. Quote "Who is John Galt?"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.