in

C1 Community

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

How to add a table programmatically with c# instead of using the designer

Last post 07-01-2008 5:14 PM by C1_IrinaP. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-30-2008 7:57 AM

    How to add a table programmatically with c# instead of using the designer

    Hello,

     Could someone show me some code where I can add a table programmatically with c#  into the Scheduler?  I am trying to match up the columns from my table to the various fields in the Appointments object.  I know in the help files it says to use the Datastorage property under the Scheduler but this is not ideal for my app.

     

    Thanks.2
  • 06-30-2008 1:19 PM In reply to

    Re: How to add a table programmatically with c# instead of using the designer

    DataStorage is the only way to show up data to C1Scheduler. you can map columns into fiedds of appoinment object by xaml like below sample or set it in c#.

    <c1sched:NestedPropertySetter

    PropertyName="DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName" Value="ScheduleUID" />

    <c1sched:NestedPropertySetter

    PropertyName="DataStorage.AppointmentStorage.Mappings.Subject.MappingName" Value="Subject"/>

    <c1sched:NestedPropertySetter

    PropertyName="DataStorage.AppointmentStorage.Mappings.Body.MappingName" Value="Content"/>

    <c1sched:NestedPropertySetter

    PropertyName="DataStorage.AppointmentStorage.Mappings.Start.MappingName" Value="StartDate"/>

    <c1sched:NestedPropertySetter

    PropertyName="DataStorage.AppointmentStorage.Mappings.End.MappingName" Value="EndDate"/>

    <c1sched:NestedPropertySetter

    PropertyName="DataStorage.AppointmentStorage.Mappings.Location.MappingName" Value="Location"/>

     

  • 06-30-2008 5:07 PM In reply to

    Re: How to add a table programmatically with c# instead of using the designer

    You should set column mappings, DataSource and DataMember for AppointmentStorage: 

      <my:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.DataMember"
        Value="Appointments"/>
       <my:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.DataSource"
        Value="{DynamicResource dataSet}"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName"
        Value="Properties"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.Body.MappingName"
        Value="Body"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.End.MappingName"
        Value="End"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName"
        Value="Id"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.Location.MappingName"
        Value="Location"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.Start.MappingName"
        Value="Start"/>
       <my:NestedPropertySetter
        PropertyName="DataStorage.AppointmentStorage.Mappings.Subject.MappingName"
        Value="Subject"/>

    You can do that from code: 

    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName
    = "Properties";
    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.Body.MappingName = "Body";
    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.End.MappingName = "End";
    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName = "Id";
    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.Location.MappingName =
    "Location";
    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.Start.MappingName = "Start";
    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.Subject.MappingName =
    "Subject";
    // this.c1Schedule1.DataStorage.AppointmentStorage.DataMember = "Appointments";
    // this.c1Schedule1.DataStorage.AppointmentStorage.DataSource = this.nwindDataSet;
    this.c1Schedule1.DataStorage.AppointmentStorage.DataSource = myDataTable;

     

  • 07-01-2008 11:10 AM In reply to

    Re: How to add a table programmatically with c# instead of using the designer

    Hello,

    I am looking through the online help and I am not finding the info I need...

     
     So I have a few questions....

     

    1) My first question....

    this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName = "Properties"; 

     What exactly is properties?  What kind of field should it be mapped to in the scheduler table?

    2) Can the  this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName  be mapped to a integer field in the table?  (Is there a place where to find this info?) 

     
    3) Is there someway to bind the   this.c1Schedule1.DataStorage.AppointmentStorage.DataSource   to a DataView?  Is that possible?   I am also getting a exception when I try to bind this DataSource to a DataTable....

     

    Regards,

     

    ---Dave 

  • 07-01-2008 5:14 PM In reply to

    Re: How to add a table programmatically with c# instead of using the designer

    > this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName
    > = "Properties";
    > What exactly is properties? What kind of field should it be mapped to in the scheduler
    > table?
    "Properties" is a name of field in your DataTable. If you use MS Access, it might be Memo
    field or long Text field.
    All appointment properties such as Label, Status, Categories, Reminder, Action, etc..
    would be saved in this field in xml form.

    > 2) Can the
    > this.c1Schedule1.DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName be
    > mapped to a integer field in the table? (Is there a place where to find this info?)

    Look at the next properties of MappingInfo class:

    ///
    /// Gets the Type value determining the type of the data field
    /// or property which can be bound to this object. It will return type of guid for
    IdMapping.
    ///
    public Type DataType { get; }

    ///
    /// Gets or sets the String value determining the name of the data field
    /// or property to be bound to the object (to Appointment object in case of
    AppointmentStorage).
    ///
    public string MappingName { get; set; }

    ///
    /// Gets the value indicating if mapping for this property is
    required or optional.
    /// It is optional for IdMapping.
    ///
    public bool Required { get; }

    ///
    /// Gets the String value determining the name of the property which should be mapped.
    /// For AppointmentStorage it would be the name of corresponding Appointment property.
    ///
    public string PropertyName { get; }

    You can always check which data type can be mapped with every mapping.
    Make sure, that you set all required mappings. In other case you'll get run-time
    exception.

    If you want to use integer key for appointments, use IndexMapping instead of IdMapping.
    You can use either of them according to your needs.

    > 3) Is there someway to bind the
    > this.c1Schedule1.DataStorage.AppointmentStorage.DataSource to a DataView? Is that
    > possible?
    It should be possible.

    > I am also getting a exception when I try to bind this DataSource to a DataTable....
    Check all mappings once more:
    - all required mappings should be set before setting AppointmentStorage.DataSource to
    your DataTable;
    - your data for eache mapping should correspond to mapping.DataType property.
Page 1 of 1 (5 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.