【问题标题】:DevExpress Winforms Grid how to set focus to a rowDevExpress Winforms Grid如何将焦点设置到一行
【发布时间】:2017-04-14 19:02:40
【问题描述】:

要利用 DevExpress Winforms XtraGrid 增量搜索,用户必须先单击一行,然后再输入。

如何以编程方式将焦点设置在第一行,以避免该步骤?

在控件的 DataSourceChanged 事件中,我尝试将焦点设置到控件本身

       gridControl1.Focus();

或其默认视图

      gridControl1.DefaultView.Focus();

但两者都没有达到预期的效果。

也尝试过设置 FocusedRowHandle:

        gridControl1.DataSource = T;
        this.gridView1.FocusedRowHandle = 0;

【问题讨论】:

    标签: winforms xtragrid devexpress-windows-ui


    【解决方案1】:

    试试这个:

    private void gridControl1_DataSourceChanged(object sender, EventArgs e)
    {
      this.ActiveControl = this.gridControl1;
      this.gridView1.FocusedRowHandle = 0;
    }
    

    【讨论】:

    • 设置 ActiveControl 就是答案。谢谢
    猜你喜欢
    • 1970-01-01
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多