有没有办法禁用左右箭头键?因为我不希望用户看到10 october
之前的日期和16 october
之后的日期
我试过这段代码
private void schedulerControl1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Right)
{
e.Handled = true;
}
}
它仍然可以点击箭头键,我检查schedulercontrol
属性没有keypreview
。或者可能设置禁用用户无法点击或关注单元格
n.b:iam使用devexpress
与组件scheduler
答案 0 :(得分:1)
您可以使用IKeyboardHandlerService。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
IKeyboardHandlerService oldKeyboardHandler = (IKeyboardHandlerService)schedulerControl1.GetService(typeof(IKeyboardHandlerService));
if (oldKeyboardHandler != null)
{
MyKeyboardHandlerService newKeyboardHandler = new MyKeyboardHandlerService(schedulerControl1, oldKeyboardHandler);
schedulerControl1.RemoveService(typeof(IKeyboardHandlerService));
schedulerControl1.AddService(typeof(IKeyboardHandlerService), newKeyboardHandler);
}
}
}
public class MyKeyboardHandlerService : KeyboardHandlerServiceWrapper
{
IServiceProvider provider;
public MyKeyboardHandlerService(IServiceProvider provider, IKeyboardHandlerService service)
: base(service)
{
this.provider = provider;
}
public override void OnKeyDown(KeyEventArgs e)
{
if (!(e.KeyCode == Keys.Left|| e.KeyCode == Keys.Right))
base.OnKeyDown(e);
}
}
答案 1 :(得分:1)
请参阅这些DevExpress主题,这些主题可能类似于您的要求和控件的SchedulerControl.LimitInterval Property:
Restrict TimelineView to show only selected date range
Scheduler: Limit days/hours displayed in Gantt-view
Restricting Date Range in Schedule Control, TimeScale view
Limit timeline view to specified interval (1 day?)
Timeline view : how to adjust the number of visible days