2013-04-24 23 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

相關問題