Kinga Kalinowska Kinga Kalinowska -4 years ago 131
C# Question

Why I dont see a MessageBox? c#

I have just created a program with that code:

class INF2 : Form1
{
public void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Zaznacz();

}
private void Zaznacz()
{

if (checkBox1.Checked == true)
{

MessageBox.Show("Dot Net Perls is awesome.");
}

}
}


where the function inherits from:

public void checkBox1_CheckedChanged(object sender, EventArgs e)
{


}


inside the
Form1
( it's a normal checkBox) and I want to see a messagebox when I press the checkbox by the
INF2
class (necessarily inheritance)

Answer Source

Read your compiler warnings.

You created a new method that happens to have the same name as the base method, but doesn't actually have anything to do with it.

You need to use virtual and override.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download