2013-04-24 55 views

回答

0
using System.Threading; 
    using System.Text.RegularExpressions; 
    using System.Data.Odbc; 
    using DevExpress.XtraEditors.Controls; 
    using DevExpress.XtraEditors; 

    namespace Project 
    { 
    public partial class frmSchedule : Form 
    { 

     DataSet scheduleDataset; 
     SQLConnection scheduleConn; 
     SQLDataAdapter scheduleAdapter; 
     private void Form1_Load(object sender, EventArgs e) 
       {    
         schedulerControl1.Start = DateTime.Now; 
         scheduleDataset = new DataSet(); 
         scheduleConn = objconnection.getConnection();// DatabaseConnection 
         scheduleConn.Open();    
         fillData("SELECT * FROM table_name"); 
       } 

     private void fillData(string query) 
      { 
       scheduleDataset = new DataSet(); 
       scheduleAdapter = new SQLDataAdapter(query, scheduleConn); 
       scheduleAdapter.RowUpdated += new SQLRowUpdatedEventHandler(scheduleAdapter_RowUpdated); 
       scheduleAdapter.Fill(scheduleDataset, "table_name"); 

       this.appointmentsBS.DataSource = scheduleDataset; 
       this.appointmentsBS.DataMember = "table_name"; 
       this.appointmentsBS.Position = 0; 

            this.schedulerStorage1.Appointments.DataSource = this.appointmentsBS; 
            this.schedulerStorage1.Appointments.Mappings.field1= "Field1";   
            this.schedulerStorage1.Appointments.Mappings.Field2= "Field2"; 



           AppointmentCustomFieldMapping IDD = new AppointmentCustomFieldMapping("IDD", "IDD"); 
           schedulerStorage1.Appointments.CustomFieldMappings.Add(IDD); 


       SQLCommandBuilder cmdBuilder = new SQLCommandBuilder(scheduleAdapter); 
       scheduleAdapter.InsertCommand = cmdBuilder.GetInsertCommand(); 
       scheduleAdapter.DeleteCommand = cmdBuilder.GetDeleteCommand(); 
       scheduleAdapter.UpdateCommand = cmdBuilder.GetUpdateCommand(); 
      } 
} 
} 
+0

感谢您的回复,我不希望使用任何数据库。只需简单地在schedulerControl中显示一个脚本和一些数据即可。 谢谢。 – 2013-04-25 04:34:50

+0

我刚刚编辑了答案,你应该使用schedulerStorage也创建一个约束源约会希望这可以帮助你。 – star 2013-04-25 08:58:46

0

您需要使用Appointments Mapping作为数据库tabel。 首先,在DataTabel中加载数据库表格并使用映射方法映射字段。

尝试寻找这段代码:Devexpress Mapping