Reputation:
When I am trying to change color of my Label, my compiler shows me an error, why ? How I can resolve this ? Thank you.
Error: does not contain a definition for 'TextColor' and no extension method 'TextColor' accepting a first argument of type 'H_M.Form1 has been found.
Code:
private void UAVON_Click(object sender, EventArgs e)
{
this.TextColor = Color.Red;
}
Upvotes: 0
Views: 143
Reputation: 101681
my compiler shows me an error, why ?
Well, you are not referring to your label.this
refers to your current Form instance.You need to access your label by it's name and like labelName.Property = something
, and there is no TextColor
property on label if you are using WinForms, I think you are looking for ForeColor
property.
Upvotes: 1
Reputation: 429
I believe the code for this should be
this.labelname.ForeColor = Color.Red;
Upvotes: 0