开发者

Why doesn't the Visual Studio designer want me to change event names in code?

I have a question about C# Event naming conventions:

private void button21_Click(object se开发者_如何学Cnder, EventArgs e) { /// CODE /// }
private void button22_Click(object sender, EventArgs e) { /// CODE /// }
private void button23_Click(object sender, EventArgs e) { /// CODE /// }

The designer warned that I should leave designer code unchanged. How then do I change the names to something more meaningful if I can't change it in the designer.cs file?


Try naming the buttons better. That way the event handler will read better.


The issue with the names is the numbering.

the designer, by default, gives objects names like classtypeN where N is an increasing number.

Go to the designer, click on the object, go to the properties ,and rename it there.

Then you won't have your conflict with designer


I developed a habit of renaming each control first thing after I drop them on a form. I don't like going back and renaming all event handlers from e.g. button1_Click to btnClickMe_Click. The actual convention I use depends on the project's convention but I always try not to forget about renaming controls.

Below is a link with some prefixes for common controls.

http://support.microsoft.com/kb/173738

You may also try the ux or _ux prefix style

www.cyberbrutus.com/naming-conventions-c/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜