In my C# code, I am having trouble implementing a System.Windows.Forms.Label
into my class. I am trying to achieve a label with a transparent background so I can put this on a transparent window to have 'floating' text.
Here is my code:
72| public class floatingText : System.Windows.Forms.Label
73| {
74| this.Text = "Words go here";
75| this.TextAlign = System.Drawing.ContentAlignment.TopCenter;
76| this.ForeColor = Color.WhiteSmoke;
77| this.BackColor = Color.Black;
78| this.TransparencyKey = Color.Black;
79| }
This code gives me the following compile errors:
74| Invalid token '=' in class, struct, or interface member declaration (CS1519)
74| Invalid token 'this' in class, struct, or interface member declaration (CS1519)
75| Invalid token ';' in class, struct, or interface member declaration (CS1519)
75| Invalid token '=' in class, struct, or interface member declaration (CS1519)
76| Invalid token ';' in class, struct, or interface member declaration (CS1519)
76| Invalid token '=' in class, struct, or interface member declaration (CS1519)
77| Invalid token ';' in class, struct, or interface member declaration (CS1519)
77| Invalid token '=' in class, struct, or interface member declaration (CS1519)
78| Invalid token ';' in class, struct, or interface member declaration (CS1519)
78| Invalid token '=' in class, struct, or interface member declaration (CS1519)
I am new to C# and have absolutely no idea what is going on here, so if you could explain this in the simple terms, that would be much appreciated ;).
I am using SharpDevelop 4.3.3 and am running Windows XP Professional
You could set the properties in a constructor like so:
Labels don't have a TransparencyKey so you may want to change the last line or did you mean to set this on the Form?