我正在使用devexpress xtrascheduler,因为我需要在点击xtrascheduler上的特定日期时获取下一个表单的日期
例如,如果我点击一个日期为02-06-2010的单元格,那么当另一个表格打开时,它就会把那个日期弄错......是否可能......
答案 0 :(得分:0)
是的,当然有可能。只需在打开新页面之前获取xtrascheduler值,然后设置 日期时间日期;
转到其他表单的代码。你有像
这样的一行public MyForm()
{
InitializeComponents();
}
也添加这一行,并在global处声明一个变量,并将其设置为传入日期,如
DateTime incomingDate = new DateTime(); // This is in the global
public MyForm(DateTime date)
{
incomingDate = date;
InitializeComponents();
}
现在,当您尝试打开新表单时,会询问datetime参数,例如
MyForm frm = new MyForm(date);
frm.Show();
----------第二种方式
表格FirstForm =您的主表格
表格SecondForm =您的第二个表格,该日期将转移到此表格
表格SecondForm:
public SecondForm(FirstForm x) // Request first form to opening
{
InitializeComponents();
}
将您的日期时间值设置为FirstForm中的变量。让我们说
// located global of your FirstForm
public DateTime abc = yourDateTime;
declare new FirstForm at SecondForm global like:
public FirstForm myFirstForm; // this is in the second form global
在这部分使用:
public SecondForm(FirstForm x)
{
InitializeComponents();
myFirstForm = x; // So now you can reach myFirstForm.abc which is your dateTime
}
只需在打开
之前以第一种形式发送此参数SecondForm frm = new SecondForm(this);
frm.Show();
计划程序控制
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.Persistent.Base.General;
using DevExpress.XtraScheduler;
namespace HowToAccessSchedulerControl.Module.Win {
public partial class SchedulerController : ViewController {
public SchedulerController() {
InitializeComponent();
RegisterActions(components);
}
private void SchedulerController_Activated(object sender, EventArgs e) {
if(View.ObjectTypeInfo.Implements<IEvent>())
View.ControlsCreated += new EventHandler(View_ControlsCreated);
}
void View_ControlsCreated(object sender, EventArgs e) {
// Access the current List View
ListView view = (ListView)View;
// Access the View's List Editor as a SchedulerListEditor
SchedulerListEditor listEditor = (SchedulerListEditor)view.Editor;
// Access the List Editor's SchedulerControl
SchedulerControl scheduler = listEditor.SchedulerControl;
// Set the desired time to be visible
if (scheduler != null)
scheduler.Views.DayView.VisibleTime =
new TimeOfDayInterval(new TimeSpan(6, 0, 0), new TimeSpan(11, 0, 0));
}
}
}