Embedded user controls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Kelly

    #1

    Embedded user controls

    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

    #2
    Re: Embedded user controls

    On 2007-11-29 13:48:08 -0800, Dave Kelly <Dave.a.Kelly@g ooglemail.comsa id:
    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.
    >
    [...]
    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

    Comment

    • Dave Kelly

      #3
      Re: Embedded user controls

      On 29 Nov, 23:35, Peter Duniho <NpOeStPe...@Nn OwSlPiAnMk.comw rote:
      On 2007-11-29 13:48:08 -0800, Dave Kelly <Dave.a.Ke...@g ooglemail.comsa id:
      >
      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.
      >
      [...]
      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
      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 programmaticall y 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.

      Comment

      • Peter Duniho

        #4
        Re: Embedded user controls

        On 2007-11-30 02:44:30 -0800, Dave Kelly <Dave.a.Kelly@g ooglemail.comsa id:
        [...]
        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

        Comment

        Working...