in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Creating a User Control inheriting from C1Schedule

Last post 02-28-2008 6:35 AM by C1_IrinaP. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-26-2008 1:13 AM

    Creating a User Control inheriting from C1Schedule

    How do I do this in VB in VS2005?  I try creating a User Control and then going into the designer.vb file and changing the inheritance statement to C1.Win.C1Schedule.C1Schedule and that seems to work fine - the C1Schedule component renders on the User Control.  But when I try to get any further, things fall apart.
     

    In the first place, if I go into the new User Component code and create a constructor and try to add anything after InitializeComponnt, like Me.VisualStyle = etc., it  blows up when I try to load the form and throws a NullReferenceException, telling me to use the "New" keyword to create an instance.  I tried adding MyBase.New() before InitializeComponent - because I saw that somewhere - but it made no difference.

    In the second place (although really in the first place temporally, as it occurs before the above), when I try to load the form that has the user control I get a ComponentOne dialog telling me I have to recompile with a licensed version of the product not to see this dialog.  I have a licensed version, and I only see this dialog when I try to use the User Control.

    I do compile the component for release before debugging.  I have it listed on the toolbox and dropped it to the form from there.

     

    What's the trick?  Does anybody have an example in VB of creating a User Control from C1Schedule?  There's a C# example of this somewhere in the forum - but it does something weird with a partial class instead of inheritance and I couldn't make much sense out of it.  I don't know C#.

     


     

  • 02-26-2008 12:20 PM In reply to

    Re: Creating a User Control inheriting from C1Schedule

     Ok, ComponentOne support has helped me resolve the licensing issue.  I needed to drop the C1Schedule component on the form first to create the licenses.licx file in the project, then delete the control (but the licenses.licx file stays), and then I don't get the license splash screen when I place a User Control that contains the C1Schedule on the form.

    As far as not being able to initialize properties in the constructor... I can change those properties in the form code once I have the control on the form... maybe I'm confused about how to modify a User Control at design time.  Again, an example in VB of a C1Schedule-based User Control with some code to extend some aspect of its functionality would be great.
     

  • 02-27-2008 6:54 AM In reply to

    Re: Creating a User Control inheriting from C1Schedule

    Look at attached project, hope that helps.

    > As far as not being able to initialize properties in the constructor... I can change
    > those properties in the form code once I have the control on the form... maybe I'm
    > confused about how to modify a User Control at design time. Again, an example in VB of
    > a C1Schedule-based User Control with some code to extend some aspect of its
    > functionality would be great.
    >
  • 02-27-2008 8:24 PM In reply to

    Re: Creating a User Control inheriting from C1Schedule

     I appreciate your help, but it doesn't work.  When I load your sample, it does something similar to what mine does (or is now doing since I closed and reopened VS2005).  Instead of rendering the C1Schedule in design view, it throws up a bunch of scary errors like:

    Warning    1    Could not find type 'WindowsApplication22.UserControl1'.  Please make sure that the assembly that contains this type is referenced.  If this type is a part of your development project, make sure that the project has been successfully built.        0    0 

    Warning    2    The variable 'UserControl11' is either undeclared or was never assigned. E:\C1CalendarUserControlExample\CustomControlTest\Form1.Designer.vb    67    0  
     


    The first error doesn't show where the error is being generated.  You placed the User Control in the same project so I don't see why it wouldn't be able to find it.  I tried building the project using both Debug and Release modes.
     

    Here's the offending line of code in Form1.designer.vb:

    Me.Controls.Add(Me.UserControl11)

    The control was declared and assigned several lines above that with:

    Me.UserControl11 = New WindowsApplication22.UserControl1

    So I don't know what the problem is.

     

  • 02-28-2008 6:35 AM In reply to

    Re: Creating a User Control inheriting from C1Schedule

    It should find UserControl1 after rebuilding the project. Please, make sure that reference
    to C1Schedule control is correct for your environment and re-build the project.
    It works for me just perfect.

    >I appreciate your help, but it doesn't work. When I load your sample, it does something
    >similar to what mine does (or is now doing since I closed and reopened VS2005). Instead
    >of rendering the C1Schedule in design view, it throws up a bunch of scary errors like:
    >
    > Warning 1 Could not find type 'WindowsApplication22.UserControl1'. Please make
    > sure that the assembly that contains this type is referenced. If this type is a part of
    > your development project, make sure that the project has been successfully built.
    > 0 0
    >
    >
    > Warning 2 The variable 'UserControl11' is either undeclared or was never assigned.
    > E:\C1CalendarUserControlExample\CustomControlTest\Form1.Designer.vb 67 0
    >
    >
    >
    > The first error doesn't show where the error is being generated. You placed the User
    > Control in the same project so I don't see why it wouldn't be able to find it. I tried
    > building the project using both Debug and Release modes.
    >
    >
    > Here's the offending line of code in Form1.designer.vb:
    >
    > Me.Controls.Add(Me.UserControl11)
    >
    > The control was declared and assigned several lines above that with:
    >
    > Me.UserControl11 = New WindowsApplication22.UserControl1
    >
    > So I don't know what the problem is.
    >
Page 1 of 1 (5 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.