[英]SelectNextControl not working on telerik drop down list
VS 2017-Windows Form應用程序-當前的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);
}
如果有更好的方法可以完成此操作,我認為已經有人發布了。
這是我正在使用的解決方案,並且運行良好:
if (ActiveControl.Parent.Name.ToString() == "order_address_dd")
{
SendKeys.Send("{TAB}");
}
else
{
this.SelectNextControl((Control)ActiveControl, true, true, true, true);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.