My "user control" turned into a "component"

  • Thread starter Thread starter Bert Hyman
  • Start date Start date
B

Bert Hyman

I have a project, part of a larger solution, that contains a handful
of user controls, each derived from a single base control.

The definition of the base control is:

public class ctlBase: System.Windows.Forms.UserControl

there's also an interface definition:

public interface IMMCInterface

Each of the derived controls looks like this:

public class ctlAnalysis : ctlBase, IMMCInterface
public class ctlCharts : ctlBase, IMMCInterface
.... etc

In the "Solution Explorer" view of VS.NET's IDE, the "ctlCharts"
control shows up as a "Component", rather than a "User Control". In
the project file itself, it's also listed as a "Component". It ->used
to show up as a "User Control", but I don't know when it changed, and
certainly don't know why.

If I edit the project file and change it back to a "User Control", it
gets changed back to a "Component" as soon as I open the project in
the IDE.

The project builds OK and works OK, and the Design View works fine
too.

What's going on here?
 
Hello Bert,

Thanks for your post. As I understand, the problem you are facing is that a
specific control "ctlCharts" is listed in the "Component" panel of
"Toolbox", while other customer controls are shown in the "User Control"
panel in "Toolbox". Please correct me if there is any misunderstanding. Now
I'd like to share the following informtion with you:

Based on my experience, this information is persisted in Visual Studio .NET
IDE. I suggest you to drag and drop the "ctlCharts" from "Component" panel
to "User Control" panel, close Visual Studio .NET and reopen it to check
whether or not it works properly.

In addition, you can also create a new ControlLibrary project, add "Cumstom
Control" and "Inherited User Control" to see if the problem occurs to other
projects and controls.

If the problem persists, could you please post a simple project which is
able to reproduce the problem? I will be glad to check it on my side.

I look forward to hearing from you.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
(e-mail address removed) (Tian Min Huang) wrote in
Hello Bert,

Thanks for your post. As I understand, the problem you are facing
is that a specific control "ctlCharts" is listed in the "Component"
panel of "Toolbox", while other customer controls are shown in the
"User Control" panel in "Toolbox". Please correct me if there is
any misunderstanding.

No, that's not what's happening.

The problem I'm seeing is in the "Solution Explorer" window which
displays a tree view of all the projects in the solution and then
shows all the files which make up each project.

In this particular case, the project contains a handful of user
controls. All of them used to display the usual "user control" icon,
but the one I've been working on furiously over the past few weeks
has changed from a "user control" into a "component".

If I examine the .project file with a text editor, I see this:

<Files>
<Include>
...
<File
RelPath = "ctlAnalysis.cs"
SubType = "UserControl"
BuildAction = "Compile"
/>
<File
RelPath = "ctlCharts.cs"
SubType = "Component"
BuildAction = "Compile"
/>
... etc

where the "SubType" for "ctlCharts.cs" has somehow been changed by
VS.NET from "UserControl" to "Component". If I manually change it
back to "User Control", the IDE changes it to "Component" the next
time I open the project.

I have no idea how or why this happened.

So far, I've seen no other side effects of this change. The project
still builds correctly and the resulting .dll assembly works
correctly when used in the completed application.

If this is merely a cosmetic effect, I'm not going to worry about it
any more, but since it's a complete mystery to me, I feel that I have
to pursue it.
 
I have seen this with code classes that are shown as components. This
happens if for example you add a class that inherits from a control.
I have tested that it happens with usercontrols too, which is your case:

Public Class UserControl1
Inherits System.Windows.Forms.UserControl
....
End Class

Public Class ComboboxEx
Inherits ComboBox
....
End Class

HTH,

Carlos Quintero
 
(e-mail address removed) (Bert Hyman) wrote in
In this particular case, the project contains a handful of user
controls. All of them used to display the usual "user control" icon,
but the one I've been working on furiously over the past few weeks
has changed from a "user control" into a "component".

Found my problem.

I had derived classes from ListView and ComboBox and to avoid adding two
new files to the project, I had simply included the class definitions in
the source file containing the man user control.

By moving the derived ListView and ComboBox code to their own files in
the project, the original user control turned back into a user control
in the project definition.

So, the "problem", if it ever actually was a problem, has been solved.
 
Back
Top