visual studio 2003 trashes my code. fix?

  • Thread starter Thread starter Dica
  • Start date Start date
D

Dica

this is related to an earlier question i had. i'm trying to figure out
visual studio 2003 and c#. i started a simple app to try to learn the
basics and used many of the wizards to set up things like my database
connection strings, etc. once i had the basic form set up, i went to hand
edit the code, made a few revisions, and then went back to design view. my
hand written revisions stay the way i've written them just fine until i use
design view to change anything else on the form, like simply adding a new
text field. now, when i go back to code view, all my revisions are removed.
i even noticed that my revisions to the database connection string (i had to
provide the password="" value manually since it wasn't offered as a choice
in design view) has been changed and my db connection no longer works.

at first, i assumed that there were some errors in my code that design view
couldn't understand, so it simply regressed the code to a state it could.
since then, however, i've removed any lines of code that were flagged as
problematic and can now compile the app just fine, but the editor still
regresses the code.

i've googled this and it looks like i'm not the first person to have this
problem, but the only viable fix i've found so far is to not use the editor
in design view. that may be perfectly sage advice to advanced coders, but to
somebody like me who relies on the editor to expose object's properties and
methods, this just isn't an option.

does anybody know a fix? if not, can anybody recommend an editor that won't
trash my code when switching between code and design view?

tks
 
Dica said:
this is related to an earlier question i had. i'm trying to figure out
visual studio 2003 and c#. i started a simple app to try to learn the
basics and used many of the wizards to set up things like my database
connection strings, etc. once i had the basic form set up, i went to hand
edit the code, made a few revisions, and then went back to design view. my
hand written revisions stay the way i've written them just fine until i
use
design view to change anything else on the form, like simply adding a new
text field. now, when i go back to code view, all my revisions are
removed.
i even noticed that my revisions to the database connection string (i had
to
provide the password="" value manually since it wasn't offered as a choice
in design view) has been changed and my db connection no longer works.

at first, i assumed that there were some errors in my code that design
view
couldn't understand, so it simply regressed the code to a state it could.
since then, however, i've removed any lines of code that were flagged as
problematic and can now compile the app just fine, but the editor still
regresses the code.

i've googled this and it looks like i'm not the first person to have this
problem, but the only viable fix i've found so far is to not use the
editor
in design view. that may be perfectly sage advice to advanced coders, but
to
somebody like me who relies on the editor to expose object's properties
and
methods, this just isn't an option.

does anybody know a fix? if not, can anybody recommend an editor that
won't
trash my code when switching between code and design view?

If I'm not mistaking the generated method has a comment telling you not to
change the code inside. This has always been one of those problems I wonder
at.

Make your changes just after the call to InitalizeComponent. The editor
doesn't care about anything outside of that method.
 
Daniel O'Connell said:
If I'm not mistaking the generated method has a comment telling you not to
change the code inside. This has always been one of those problems I wonder
at.

oh boy, do i ever feel like a boob. yes, you're right, there are comments
there telling me not to edit the initializeComponent code.

tks
 
Back
Top