سؤال

In the WindowsForms after double click on label, for example, I'm getting a code:

private void label1_Click(object sender, EventArgs e)
        {

        }

And if I'll delete it, it will be an error on the form's window, which want me to return the code. How can I delete it?

هل كانت مفيدة؟

المحلول

Open designer, select label1 and remove Click event handler in label's events list (Properties window).

نصائح أخرى

On the Designer, locate the label1, then look at the Properties for that label and remove the event handler defined for the OnClick event. You can then delete the code.

Picture says a thousand words:

enter image description here

You have to remove the event handler either from the form designer.cs or from the property tab

First you need to remove it from the Properties window in the designer.

You have to remove the method name from the Events tab in the Properties window. After that it will either be automatically removed or you can delete it without issue.

You might also have to go into the automatically generated design code file and take out the part that adds that method as an event handler for your label.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top