自动重新生成设计器文件 [英] Automatic regenerate designer files

查看:85
本文介绍了自动重新生成设计器文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我对我们使用的许多控件进行了一些改进,例如为属性设置默认值,并将按钮设置为私有而不是受保护。
通过进行这种调整,您需要重新生成具有此控件或从控件继承的控件的表单的设计器文件。

Recently I've been making some improvements to a lot of the controls we use, for example give properties default values and making buttons private instead of protected. By making this kind of adjustments you need to regenerate the designer files of the forms which have this control on it or controls which inherit from the control.

在过去这并不是一个真正的问题,因为我们只有20到30个表格。目前,我们有300多种表单,这意味着在VS2010中打开相同数量的设计师。

In the past this wasn't really a problem because we only had 20-30 forms. At the moment we've got more than 300 forms which would mean opening the same amount of designers in VS2010.

所以我的问题是:您知道一种自动化的方法吗?

So my question: do you know a way of automating this process so all of the forms get regenerated?

我一直在考虑寻找设计器文件并打开文件的宏(最多25-50个文件)打开以确保VS不会崩溃),但我无法使它正常工作。

I've been thinking about a macro which looks for designer files and opens the file (with a max of 25-50 files open to make sure VS won't crash), but I've not been able to get this working.

我希望有人提出建议!

推荐答案

我发现唯一要做的事情是打开表单设计器,添加控件,然后保存。这将重新生成设计器代码。接下来,删除新添加的控件,再次保存并关闭。

The only way I found to do what you want, is to open the form designer, add a control, then save. This will regenerate the designer code. Next delete the newly added control, save again, and close.

我通常通过双击工具箱中的按钮来添加按钮。这会将按钮放在位置0,0。

I usually add a button by double-clicking on the button in the toolbox. This puts the button at location 0,0.

几个月前,我用一个包含大约100个表单和用户控件的项目进行了此操作。我记录了一个临时宏,然后运行了每个表单/用户控件的宏,并检查了结果,而不是递归于项目文件的宏。

I did this a couple months ago with a project with about 100 form and user-controls. Instead of a macro that recursed over the project files, I recorded a temporary macro then ran the macro for each form/user-control and inspected the results.

不要将重构与重新格式化混淆。我经常以较大的形式优化和/或修改设计器代码。例如,我将更改添加到面板的顺序控件以及如何将面板添加到其他面板。 我不会盲目地重新生成设计器代码。

Do not confuse refactoring with reformatting. I often optimize and/or modify the designer code in large forms. For example, I will change the order controls are added to panels, and how panels are added to other panels. I would not blindly regenerate the designer code.

这篇关于自动重新生成设计器文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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