Automatic regenerate designer files

拈花ヽ惹草 提交于 2019-12-03 05:35:30

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.

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

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.

Pondidum

I also ran into this problem (see also: Force WinForms to regenerate .designer.cs files).

In the end, most of the properties I removed were uniquely named, and I was able to write a shell script to remove lines from the designer files that contained the property names.

Note, this actually removes the line, not just leaving a blank line.
It needs to be run from a Bash Shell, if you have msysgit installed, that shell is fine.
In this one, TextForeColor was the property being removed.

#!/bin/bash
files=$(find . -type f -name '*.Designer.cs' -print0 | xargs -0 grep -l 'TextForeColor')
for file in $files
do
    echo $file
    sed '/TextForeColor/ d' $file >$file.tmp
    mv $file.tmp $file
done

Employ form's inheritance instead of maintaining changes over 300 controls.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!