如何从自定义用户控件中删除属性 [英] How to remove a property from a custom user control

查看:41
本文介绍了如何从自定义用户控件中删除属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

属性已添加到自定义用户控件.从那时起,Visual Studio 已将生成的代码插入到使用该用户控件的每个窗体中.现在我们要删除该属性,因为它不会被使用.但显然这样做会导致编译错误.有没有办法告诉 Visual Studio 从所有生成的代码中删除属性?在我看来,像 [Obsolete()] 这样的东西应该足以告诉 Visual Studio 从生成的代码中删除它.还有其他方法吗?

A property was added to a custom user control. Since then, Visual Studio has inserted generated code to every form that uses that user control. Now we want to remove that property because it is not going to be used. But obviously doing so causes compile errors. Is there a way to tell Visual Studio to remove the property from all that generated code? It seems to me that putting something like [Obsolete()] should be enough to tell Visual Studio to remove it from the generated code. Is there some other way?

推荐答案

正则表达式来救援!我通常做的是在文件对话框中打开替换(Ctrl + Shift + H),选中使用正则表达式复选框并将 .+\.SomeProperty.+ 的实例替换为空字符串.

Regex to the rescue! What I usually do is open Replace in Files dialog (Ctrl+Shift+H), check Use Regular Expressions checkbox and replace instances of .+\.SomeProperty.+ with empty string.

请务必在之前将更改提交到存储库,以便在出现任何问题时恢复到工作状态.

Be sure to commit your changes to repository before this, so you can revert to working state if anything goes wrong.

这篇关于如何从自定义用户控件中删除属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆