Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2007

Tip: Looking for answers? Try searching our database.

Embedded user controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Kelly - 29 Nov 2007 21:48 GMT
c#, .Net 2.0, VS2008

I have a user control, and wish to embed other custom/user controls
within this control.

I am getting problems in compilation though, that the type or
namespace cannot be found.

I have used the same namespace for both components.

Everything compiles and works fine with each of the respective user
controls used in the main project. The main control is derived from
TabPage, and one of the embedded controls is derived from CheckBox.

Any way of resolving this?
Peter Duniho - 29 Nov 2007 23:35 GMT
> c#, .Net 2.0, VS2008
>
[quoted text clipped - 6 lines]
> [...]
> Any way of resolving this?

Undoubtedly.

You haven't really offered much in the way of specifics, but generally
speaking you'll get a compilation error like that if you've failed to
be specific enough about the namespace for some type you're using, or
you've failed to add a necessary reference to the project (under
"References" in the Solution Explorer).

If the former, you can solve that either by providing the fully
qualified name for the namespace before the type, or you can provide an
appropriate "using" statement at the beginning of the source file.

Not knowing the exact error, it's impossible to know what namespace or
reference hasn't been included.  But it may be as simple as needing to
add a reference to the assembly for your custom control.

Pete
Dave Kelly - 30 Nov 2007 10:44 GMT
> > c#, .Net 2.0, VS2008
>
[quoted text clipped - 24 lines]
>
> Pete

The situation is I have the source for both of the components in the
same project. Simplifying it, I have a control derived from the
TabPage, and another control derived from the CheckBox, which I wish
to programmatically place on the TabPage.

Both controls are in the same project, and using the same namespace.

I can use either control in any part of the project (eg put the
derived checkbox on the mainform), just not use it in the custom
tabpage control.

Note: I am not trying to solve the specifics of how to add the
checkbox derived control, but generically, as there are a few other
controls I wish to use on my derived TabPage.

Even when I tried to use a DLL of the custom controls, and referenced
the assembly in the project, I still got the same error.
Peter Duniho - 30 Nov 2007 18:33 GMT
> [...]
> Even when I tried to use a DLL of the custom controls, and referenced
> the assembly in the project, I still got the same error.

As I wrote, this is usually not a difficult thing to fix.  The
compilation error provides detailed information that should lead you to
a solution.

But you haven't provided enough information here for anyone else to
answer the question.  The exact wording of the compilation error and a
concise-but-complete sample of code demonstrating the problem would be
required.

You claim that both controls are in the same project and in the same
namespace.  If so, then you've either got a typo or a conflicting name
or you've failed to completely qualify a nested type or you're wrong
about them being in the same project and namespace.  As you can see,
there are a variety of things that could cause the error you're
describing and so there's no way for anyone else to know which of those
problems is actually the issue as long as you continue to withhold the
important details.

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.