0

So I'm trying to create a label with the following code :

Label letter = new Label();
String key = Convert.ToString(e.KeyChar);
letter.Text = key;
letter.ForeColor = textColor;
letter.Size = new Size(10, 20);
letterSpacing = letterSpacing + letter.Size.Width;
letter.Location = new Point(letterSpacing, (line * 18));
type.Controls.Add(letter);
letters.Add(letter); //this is a List<> of controls.

But I would also like to change the "letter" label to have the highest "z-index" or to bring it to the front of all other controls. I know that you can do this threw visual studios by right-clicking and selecting "bring to front", but is there a way to do this threw code? I also looked into the Canvas.SetZIndex method, however visual studios still throws and exception when I try this.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Ian Wise
  • 706
  • 2
  • 10
  • 31

1 Answers1

1

turns out there's a BringToFront();

I was looking for bringToFront();

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Ian Wise
  • 706
  • 2
  • 10
  • 31