【问题标题】:SelectNextControl not working on telerik drop down listSelectNextControl 不适用于 Telerik 下拉列表
【发布时间】: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);
}

【问题讨论】:

    标签: c# winforms telerik


    【解决方案1】:

    如果有更好的方法可以做到这一点,时间已经过去了,我想有人会发布它。

    这是我正在使用的解决方案,它工作正常:

    if (ActiveControl.Parent.Name.ToString() == "order_address_dd")
    {
        SendKeys.Send("{TAB}");
    }
    else
    {
        this.SelectNextControl((Control)ActiveControl, true, true, true, true);
    }
    

    【讨论】:

      猜你喜欢
      • 2014-04-05
      • 2017-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-19
      • 2021-08-27
      相关资源
      最近更新 更多