IDE

Y

Young

When I create a new form, I usually copy from and existing form that is the
closest match (controls wise) so I don't have to set all the properties
again.

I then rename the new form. The problem with this is the IDE will
automatically rename all my old forms as well.

For example, I got a form called Form1. I then create Form2 (copied from
Form1 and renamed to Form2). When I rename the form, the IDE changes all
references of Form 1 to Form2.

Can this be prevented?

Thanks
Young
 
F

Family Tree Mike

Young said:
When I create a new form, I usually copy from and existing form that is
the closest match (controls wise) so I don't have to set all the
properties again.

I then rename the new form. The problem with this is the IDE will
automatically rename all my old forms as well.

For example, I got a form called Form1. I then create Form2 (copied from
Form1 and renamed to Form2). When I rename the form, the IDE changes all
references of Form 1 to Form2.

Can this be prevented?

Thanks
Young


Are you copying (and pasting) the form in the solution explorer? When I do
that, I end up with a form shown as Copy of Form1.cs. When I rename that in
the solution explorer to form2.cs, then the next step would be to change the
class name, as it would still say Form1. At this point I will have compiler
errors regarding a naming conflict as both form1.cs and form2.cs use the
classname form1. If I rename the class to Form2 in both the designer and
code files, then it works fine. If I use the refactoring tool to rename the
form, then I will be given a choice to change all occurances (including
references) to form2. It sounds like you are using the refactoring tool to
do the rename. It would work better in this situation to not use that tool.
Just rename the class in the two source files.
 
C

Cowboy \(Gregory A. Beamer\)

Not the way you are doing it. Copy and paste refactoring is not supported by
the refactorings.

You can change the name of the second file in the file and then change the
name and say no if it asks you to change references.

if the properties you are talking about are the control properties, you can
create a new form and copy the controls from one form to another. This will
overcome your problem, as you can have textbox1 on as many forms as you
would like.

Another option is to move the control groupings to user controls and place
them on more than one form. You can then copy the controls to another user
control and make the slight alterations. This is best for reuse of specific
groups.

As far as trying the method you are doing, make a second "garbage", empty
project and move into it and then rename there. Once the form is completely
renamed, move it back into your project. Doing this will completely
circumvent the issue.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top