471,091 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

Design mode frustration -- deleting code

A quick rant and a question.

Why does the designer in VS2003 delete code about custom components that it
can't load? I've had large sections of forms disappear in the blink of an
eye just because I've introduced a small error in a widely used custom
control that makes it throw an exception at design time.

IMHO the code should be sacrosanct -- if the designer can't create some sub
control then it should just throw up a blank or a red X or something (it
would be nice if it would be smart enough to figure out where the control is
supposed to be and just mark that area) and make note of the exception. Is
there some way to stop the designer from deleteing code (aside from marking
the code read only before entering the designer, which is what I've started
doing)? Is this going to change any time soon?

Thanks,
Eric

PS This is in Visual C#, from some things I have read it behaves
differently in Visual Basic but I haven't tried that.
Nov 16 '05 #1
3 1629
It does say you shouldn't edit code in there - the designer can delete and
destroy anything it finds. From experience, it's better either doing your
own code outside the designer created code or at least keeping a copy of the
function before you go into the designer. I agree it's really irritating,
but it can be avoided (or at least made less destructive).

Steve

"Eric Hudson" <Er********@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
A quick rant and a question.

Why does the designer in VS2003 delete code about custom components that it can't load? I've had large sections of forms disappear in the blink of an
eye just because I've introduced a small error in a widely used custom
control that makes it throw an exception at design time.

IMHO the code should be sacrosanct -- if the designer can't create some sub control then it should just throw up a blank or a red X or something (it
would be nice if it would be smart enough to figure out where the control is supposed to be and just mark that area) and make note of the exception. Is there some way to stop the designer from deleteing code (aside from marking the code read only before entering the designer, which is what I've started doing)? Is this going to change any time soon?

Thanks,
Eric

PS This is in Visual C#, from some things I have read it behaves
differently in Visual Basic but I haven't tried that.

Nov 16 '05 #2
LOL. Its not fussy about whose code it deletes. It will delete its own
designer generated code just as easily.

Cheers

Doug Forster

"Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl...
It does say you shouldn't edit code in there - the designer can delete and
destroy anything it finds. From experience, it's better either doing your
own code outside the designer created code or at least keeping a copy of
the
function before you go into the designer. I agree it's really irritating,
but it can be avoided (or at least made less destructive).

Steve

"Eric Hudson" <Er********@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
A quick rant and a question.

Why does the designer in VS2003 delete code about custom components that

it
can't load? I've had large sections of forms disappear in the blink of
an
eye just because I've introduced a small error in a widely used custom
control that makes it throw an exception at design time.

IMHO the code should be sacrosanct -- if the designer can't create some

sub
control then it should just throw up a blank or a red X or something (it
would be nice if it would be smart enough to figure out where the control

is
supposed to be and just mark that area) and make note of the exception.

Is
there some way to stop the designer from deleteing code (aside from

marking
the code read only before entering the designer, which is what I've

started
doing)? Is this going to change any time soon?

Thanks,
Eric

PS This is in Visual C#, from some things I have read it behaves
differently in Visual Basic but I haven't tried that.


Nov 16 '05 #3
I guess I wasn't clear. It is deleting its own code. Here is a simple
scenario.

1) Make a custom control
2) Make a form and drop that control on it
3) Now "break" the custom control -- put something that throws an exception
in the constructor (as a trypical example I occasionally forget to hide
references to objects that are null in design mode as they get initialized at
run time)
4) Go back to the form in design mode. It will destroy all the code about
the custom control -- where it was, any initialization information.

This is stupid. One control on one form isn't too bad. But I might have 50
data entry controls on some form and if I break that control it deletes all
of them. This is obviously painful to recreate and there is just no good
reason for it as far as I can tell. If it runs into trouble why can't it
just paint the area with an error marker of some sort?

"Steve McLellan" wrote:
It does say you shouldn't edit code in there - the designer can delete and
destroy anything it finds. From experience, it's better either doing your
own code outside the designer created code or at least keeping a copy of the
function before you go into the designer. I agree it's really irritating,
but it can be avoided (or at least made less destructive).

Steve

"Eric Hudson" <Er********@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
A quick rant and a question.

Why does the designer in VS2003 delete code about custom components that

it
can't load? I've had large sections of forms disappear in the blink of an
eye just because I've introduced a small error in a widely used custom
control that makes it throw an exception at design time.

IMHO the code should be sacrosanct -- if the designer can't create some

sub
control then it should just throw up a blank or a red X or something (it
would be nice if it would be smart enough to figure out where the control

is
supposed to be and just mark that area) and make note of the exception.

Is
there some way to stop the designer from deleteing code (aside from

marking
the code read only before entering the designer, which is what I've

started
doing)? Is this going to change any time soon?

Thanks,
Eric

PS This is in Visual C#, from some things I have read it behaves
differently in Visual Basic but I haven't tried that.


Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by JJ | last post: by
9 posts views Thread by Reidar | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.