【发布时间】:2017-08-18 18:30:55
【问题描述】:
VS 2017 - Windows 窗体应用程序 - 当前 Telerik 控件
我有一个表单,我希望用户能够通过按 Enter(或 Tab)移动到下一个控件。 选项卡工作正常。
要启用输入功能,我这样做:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (ActiveControl.Name.ToString() != "order_creation_grid") //ensures that we don't caputre keypresses in the grid
{
if (keyData == Keys.Enter)
{
this.SelectNextControl((Control)ActiveControl, true, true, true, true);
这很好用,除了在下拉列表框中。 我认为是因为列表框使用 Enter 选择了当前项。 因此,我尝试执行以下操作来检查我是否在该控件中,然后手动选择正确的控件:
if (ActiveControl.Name.ToString() != "order_creation_grid") //ensures that we don't caputre keypresses in the grid
{
if (keyData == Keys.Enter)
{
if (ActiveControl.Name.ToString() == "order_address_dd")
{
order_city_eb.Select();
}
else
{
this.SelectNextControl((Control)ActiveControl, true, true, true, true);
}
}
问题是没有设置 ActiveControl.Name - 它显示“”。
ActiveControl.SelectedItem 确实在选中的下拉列表中显示文本,因此我假设我在正确的位置查找。
顺便说一句...事件确实按预期触发,SelectNextControl 不起作用。 更新:我有一个解决方法,但我确信这不是解决此问题的正确方法:
if (ActiveControl.Parent.Name.ToString() == "order_address_dd")
{
SendKeys.Send("{TAB}");
}
else
{
this.SelectNextControl((Control)ActiveControl, true, true, true, true);
}
【问题讨论】: