Please, what is wrong with this:
private void Form2_Load(object sender, EventArgs e)
{
switch (Form2.Tag) //error
{
case "desc":
MessageBox.Show("desc");
break;
case "sms":
MessageBox.Show("sms");
break;
}
}
Error:
An object reference is required for the non-static field, method, or property System.Windows.Forms.Control.Tag.get
You probably meant to say
this.Tag. Referencing theTagproperty will require an instance ofForm2, hence the error message you received.Edit:
Forgot
Tagwas an object. Cast it to a string and your statement should work: