473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

"Losing" Controls on User Controls

BBM
Hi,

I have been developing with C# User Controls and occasionally have a problem
where I "lose" a control from the design surface of the User Control. The
controls that I am using to build my User Controls are themselves custom
controls.

Occasionally, when I change something in either the User Control and/or one
of the custom controls that are on it and recompile, when I go to the
"Visual" design surface of the User Control, the custom control that used to
be on it is no longer there. But if you look at the code for the User
Control, the custom control object is still declared, and any references to
it in code are still there. But apparently it's no longer added to the User
Control in code.

I have a workaround...
1) Remove declaration of the "lost" object from the User Control code.
2) Go into the toolbox and get the custom control and put it back on the
User Control
3) Set any custom control properties that were set before, and re-register
for custom control events (because the eventhandler methods are still there
all I have to do is select the right one thank goodness)

Still, this is an ENORMOUS PAIN IN THE BUTT when it happens. Can somebody
tell me how to avoid this situation (Please don't say don't use custom
controls on User Controls).

Thanks.

BBM
Nov 16 '05 #1
10 2672
Hi,

One guess.. are you sure that you don't edit the Initializer method of the
form or the user control manually??? if you do so that may cause the error
since you are not allow to do so but If you don't.. this is some what
strange and again i don't see a reason to say not to use custom control on
another user control it cannot be the error..

Nirosh.

"BBM" <bb*@bbmcompany.com> wrote in message
news:13**********************************@microsof t.com...
Hi,

I have been developing with C# User Controls and occasionally have a problem where I "lose" a control from the design surface of the User Control. The
controls that I am using to build my User Controls are themselves custom
controls.

Occasionally, when I change something in either the User Control and/or one of the custom controls that are on it and recompile, when I go to the
"Visual" design surface of the User Control, the custom control that used to be on it is no longer there. But if you look at the code for the User
Control, the custom control object is still declared, and any references to it in code are still there. But apparently it's no longer added to the User Control in code.

I have a workaround...
1) Remove declaration of the "lost" object from the User Control code.
2) Go into the toolbox and get the custom control and put it back on the
User Control
3) Set any custom control properties that were set before, and re-register for custom control events (because the eventhandler methods are still there all I have to do is select the right one thank goodness)

Still, this is an ENORMOUS PAIN IN THE BUTT when it happens. Can somebody
tell me how to avoid this situation (Please don't say don't use custom
controls on User Controls).

Thanks.

BBM

Nov 16 '05 #2
mdb
=?Utf-8?B?QkJN?= <bb*@bbmcompany.com> wrote in
news:13**********************************@microsof t.com:
Occasionally, when I change something in either the User Control
and/or one of the custom controls that are on it and recompile, when I
go to the "Visual" design surface of the User Control, the custom
control that used to be on it is no longer there. But if you look at
the code for the User Control, the custom control object is still
declared, and any references to it in code are still there. But
apparently it's no longer added to the User Control in code.


Yeah this seems to be a problem in the design of VS.net - lots of other
people have seen similar behavior. I have noticed that it only happens
AFTER a compile (or more precisely, when the DLL has changed and thus
needs to be reloaded and the controls re-rendered to include any
changes), when you switch to the designer for that page. In other
words, if you have the designer and the code view open, and you are
looking at the code view when you compile, it MIGHT happen (and will
ONLY happen) when you switch to the design view.

What that means for me (and you, if you want to adopt this method) is
that when it happens, just exit the VS.net environment and restart it.
Everything should come back just the way it was, as long as you have
VS.net configured to automatically save the files before a compile (is
that even an option? i can't remember.) I have a fairly large and
complex project that I use this method on and its not too bad - as long
as you notice when it happens.

Obviously, this is still a pain-in-the-butt... but not as much as
having to reset the properties of the control.

The other thing that I do is that I've stopped setting the properties
that I want to change in the designer. Instead, I set them manually in
the Form_Load.

One more thing that might help but which I can't confirm (it seemed to
help for a while but then I found instances where it didn't help) is to
make sure that things like enums are defined at the namespace level, and
not inside of classes. I know it doesn't make any sense, and like I
said I've found instances where I still lost my controls, but it sure
seemed to alleviate the problem for a time.

And finally, keep the number of VS.net tabs (especially designers) that
you have open to a minimum. I personally think it has something to do
with VS.net not performing things in the right order, or not waiting for
A to finish before it tries to do B. Keeping the number of tabs open
seems to help for me - that is, it reduces how often the problem occurs.

-mdb
Nov 16 '05 #3
I've run into this problem when designing winforms. All of my "usercontrols"
are in a seperate assembly. If I have a form open in design view, and I'm
editing a usercontrol, then attempt to compile the usercontrol and it fails,
the control is removed from the form, but is still declared. Essentially my
workaround is to "NEVER" have a form open in design view that is using a
usercontrol when I'm making changes to my usercontrols. This works for me.

--
Lateralus [MCAD]
"BBM" <bb*@bbmcompany.com> wrote in message
news:E4**********************************@microsof t.com...
mdb,

Thanks for a very complete and helpful response.

I'm guilty of some of the stuff you mention: declaring enums in classes,
and
tending to have way too many tabs open in the designer.

I like your workaround a lot better than mine too.

Do you think anybody at Microsoft is working on this?

Thanks for your help.

BBM

"mdb" wrote:
=?Utf-8?B?QkJN?= <bb*@bbmcompany.com> wrote in
news:13**********************************@microsof t.com:
> Occasionally, when I change something in either the User Control
> and/or one of the custom controls that are on it and recompile, when I
> go to the "Visual" design surface of the User Control, the custom
> control that used to be on it is no longer there. But if you look at
> the code for the User Control, the custom control object is still
> declared, and any references to it in code are still there. But
> apparently it's no longer added to the User Control in code.


Yeah this seems to be a problem in the design of VS.net - lots of other
people have seen similar behavior. I have noticed that it only happens
AFTER a compile (or more precisely, when the DLL has changed and thus
needs to be reloaded and the controls re-rendered to include any
changes), when you switch to the designer for that page. In other
words, if you have the designer and the code view open, and you are
looking at the code view when you compile, it MIGHT happen (and will
ONLY happen) when you switch to the design view.

What that means for me (and you, if you want to adopt this method) is
that when it happens, just exit the VS.net environment and restart it.
Everything should come back just the way it was, as long as you have
VS.net configured to automatically save the files before a compile (is
that even an option? i can't remember.) I have a fairly large and
complex project that I use this method on and its not too bad - as long
as you notice when it happens.

Obviously, this is still a pain-in-the-butt... but not as much as
having to reset the properties of the control.

The other thing that I do is that I've stopped setting the properties
that I want to change in the designer. Instead, I set them manually in
the Form_Load.

One more thing that might help but which I can't confirm (it seemed to
help for a while but then I found instances where it didn't help) is to
make sure that things like enums are defined at the namespace level, and
not inside of classes. I know it doesn't make any sense, and like I
said I've found instances where I still lost my controls, but it sure
seemed to alleviate the problem for a time.

And finally, keep the number of VS.net tabs (especially designers) that
you have open to a minimum. I personally think it has something to do
with VS.net not performing things in the right order, or not waiting for
A to finish before it tries to do B. Keeping the number of tabs open
seems to help for me - that is, it reduces how often the problem occurs.

-mdb

Nov 16 '05 #4
Hi BBM,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you are developing a Microsoft
Windows Forms application in Microsoft Visual Studio .NET 2003, instances
of custom user controls or of derived Windows Forms controls may disappear
from the Windows Forms Designer. If there is any misunderstanding, please
feel free to let me know.

Based on my research, this is a known issue. Here is a KB article which
talk about this issue and provides a fix.

http://support.microsoft.com/default...B;EN-US;842706

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #5
BBM
Kevin,

Your reference didn't exactly address my problem, but I've gotten enough
responses from others to know that I'm not imagining this, and I have some
suggestions on how to avoid it. Do you know if this was fixed in VS.Net 2005?

"Kevin Yu [MSFT]" wrote:
Hi BBM,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you are developing a Microsoft
Windows Forms application in Microsoft Visual Studio .NET 2003, instances
of custom user controls or of derived Windows Forms controls may disappear
from the Windows Forms Designer. If there is any misunderstanding, please
feel free to let me know.

Based on my research, this is a known issue. Here is a KB article which
talk about this issue and provides a fix.

http://support.microsoft.com/default...B;EN-US;842706

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #6
Hi BBM,

As a support engineer, I'm not quite sure whether there will be fixes in
VS.NET 2005. However, you can send mails directly to ms****@microsoft.com
to report your ideas and your wishes. Your suggestions will be highly
appreciated.

Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #7
Hi Kevin,

It seems that the solution you refer to is the one I need for my problems
with user controls. On every change in my user control (which is in the same
solution as the Forms project I use the control on), the control will
disappear from my form. This is a very anoying problem, which I really want
to get solved. Now I've tried to contact the dutch MSDN support service by
telephone, but do not seem to be able to help me out with this problem. So,
my question is, can you help me out here? What I want is to get the fix for
the problem described in this article
(http://support.microsoft.com/default...;EN-US;842706). I've got an
MSDN license from which I've installed the Visual Studio .NET 2003 Enterprise
Architect, but don't understand why I cann't get to the solution of my
problem....

Thanks,
Christ
"Kevin Yu [MSFT]" wrote:
Hi BBM,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you are developing a Microsoft
Windows Forms application in Microsoft Visual Studio .NET 2003, instances
of custom user controls or of derived Windows Forms controls may disappear
from the Windows Forms Designer. If there is any misunderstanding, please
feel free to let me know.

Based on my research, this is a known issue. Here is a KB article which
talk about this issue and provides a fix.

http://support.microsoft.com/default...B;EN-US;842706

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #8
Hi Christ,

I'm not quite sure why Dutch MSDN support didn't give you the hotfix. Could
you try Microsoft PSS in other contries? For example United State?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #9
Kevin,

Is the only way in which MSDN Subcribers can receive these "hot fixes"
calling MSDN Support and using up one of our technical issue "incedents"?

"Kevin Yu [MSFT]" wrote:
Hi Christ,

I'm not quite sure why Dutch MSDN support didn't give you the hotfix. Could
you try Microsoft PSS in other contries? For example United State?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #10
Hi,

Calling Microsoft PSS for hotfix is free of charge which will not use up
one of your incidents.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
A beginner in this area, I have been able to read a record from a MySQL database and populate an HTML form (wow!). Now, my goal is to allow the user to edit the contents of the form and then...
16
by: Dave Opstad | last post by:
In this snippet: d = {'x': 1} value = d.get('x', bigscaryfunction()) the bigscaryfunction is always called, even though 'x' is a valid key. Is there a "short-circuit" version of get that...
40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
5
by: Nick Stansbury | last post by:
Hi, Sorry for the obscure title but I'm afraid I can't think of a better way to describe what happened to one of my clerks last night. The guy was working late, made a series of changes (accross a...
9
by: Dennis Ruppert | last post by:
Greetings This is rather ambitious: I have a split database that contains many different reports. I have a form that the end user launches the reports from. They select the report criteria...
7
by: Jim Bancroft | last post by:
Hi everyone, A basic one here, I think. I haven't found the pattern yet, but sometimes when I cast a variable to another type using the "C" style cast operator the compiler refuses to play...
0
by: HL | last post by:
Hi, I have a small application that authenticates the user and stores the credentials and other identity info in a session-scope object. After browsing a few pages, that session-scope object...
0
by: Stefan De Schepper | last post by:
Dear NG, I created a gridlike usercontrol. When clicking on a cell a textbox (or other control, depending on the cell's editortype) is shown. When some other control gets the focus, the textbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.