programmatically set/get DevExpress Scheduler Control (ver: 22.2.4) via C#

212 Views Asked by At

trying: programmatically set/get DevExpress Scheduler Control (ver: 22.2.4) via C#

DataTable t1 = new DataTable("Appointments");
DataColumn dc1 = t1.Columns.Add("UniqueID", typeof(int));
dc1.AutoIncrement = true;
dc1.AutoIncrementSeed = 1;
dc1.AutoIncrementStep = 1;
t1.Columns.Add("Type", typeof(int));
t1.Columns.Add("StartDate", typeof(DateTime));
t1.Columns.Add("EndDate", typeof(DateTime));
t1.Columns.Add("AllDay", typeof(bool));
t1.Columns.Add("Subject", typeof(String));
t1.Columns.Add("Location", typeof(String));
t1.Columns.Add("Description", typeof(String));
t1.Columns.Add("Status", typeof(int));
t1.Columns.Add("Label", typeof(int));
t1.Columns.Add("ResourceID", typeof(int));
t1.Columns.Add("ResourceIDs", typeof(String));
t1.Columns.Add("ReminderInfo", typeof(String));
t1.Columns.Add("RecurrenceInfo", typeof(String));
t1.Columns.Add("CustomField1", typeof(String));

DataTable t2 = new DataTable("Resources");
DataColumn dc2 = t2.Columns.Add("UniqueID", typeof(int));
dc2.AutoIncrement = true;
dc2.AutoIncrementSeed = 1;
dc2.AutoIncrementStep = 1;
t2.Columns.Add("ResourceID", typeof(int));
t2.Columns.Add("ResourceName", typeof(String));
t2.Columns.Add("Color", typeof(int));
t2.Columns.Add("Image", typeof(byte[]));
t2.Columns.Add("CustomField1", typeof(String));

schedulerControl1.DataStorage.Appointments.DataSource  = t1;
schedulerControl1.DataStorage.Resources.DataSource = t2;

However when I (via scheduler UI) enter an appointment, and look at the DataStorage via…

DataTable t1 = (DataTable)schedulerControl1.DataStorage.Appointments.DataSource;

…the datatable t1 has nothing!

Tried code above, expected 1 record in data-table t1

1

There are 1 best solutions below

0
Hailes Maurício On

dude, try this:

DataTable t1 = schedulerControl1.DataStorage.Appointments.DataSource as DataTable;

It worked for me.