简体   繁体   English

如何在devexpress网格控件中防止查找面板自动聚焦

[英]How to prevent auto focus of find panel in devexpress grid control

My form only have grid control and ribbon bar. 我的表单只有网格控件和功能区栏。 I want auto focus to first cell of grid view when form loaded. 我想在窗体加载时自动聚焦到网格视图的第一个单元格。

Problem is : when form is loaded, it auto focus in find panel of the grid instead of grid cell. 问题是:加载表单时,它将自动聚焦在网格的查找面板中,而不是网格单元中。

I tried like this but not works. 我尝试这样,但没有用。 Help, Thanks all. 帮助,谢谢大家。

    private void gcStockDelivery_Load(object sender, EventArgs e)
    {
        BeginInvoke(new MethodInvoker(() =>
        {
            gvStockDelivery.FocusedColumn = gcBarCode;
            gvStockDelivery.ShowEditor();
        }));
    }

在此处输入图片说明

Code to select other control after FormLoad() 在FormLoad()之后选择其他控件的代码

protected override void OnShown(EventArgs e)
{
    base.OnShown(e);
    txtPurchaseOrder.BeginInvoke(new Action(() =>
    {
        txtPurchaseOrder.Select();
    }));
}

Find Panel is always focused when it is visible on Form Load, so you have to change focus manually. 当“查找面板”在“表单加载”上可见时,它始终处于焦点状态,因此您必须手动更改焦点。 You have showed us the code in order to change another control. 您已向我们显示了代码,以便更改另一个控件。 What about if you selected the grid itself as control and then custom the GotFocus event you have just selected? 如果选择网格本身作为控件,然后自定义刚刚选择的GotFocus事件,该怎么办? You can try this code 您可以尝试此代码

This is your first custom: 这是您的第一个习惯:

protected override void OnShown(EventArgs e)
{
    base.OnShown(e);
    yourGridControl.BeginInvoke(new Action(() =>
    {
        yourGridControl.Select();
    }));
}

This is your second custom: 这是您的第二个习惯:

private void yourGridControl_GotFocus(Object sender, EventArgs e) {
    GridView gridView1 = Me.ViewCollection.Item(0)
    gridView1.FocusedColumn = gridView1.VisibleColumns(0)
    gridView1.FocusedRowHandle = 0

}

Sorry for late reply. 抱歉回复晚了。 I got a soultion at there XtraGrid AutoFilterRow focusing 我对XtraGrid AutoFilterRow聚焦感到很高兴

It works. 有用。

protected override void OnShown(EventArgs e)
{
    base.OnShown(e);
    gcDamageItems.BeginInvoke(new Action(() =>
    {
        gcDamageItems.ForceInitialize();
        gvDamageItems.MoveFirst();
        gvDamageItems.FocusedColumn = gvDamageItems.VisibleColumns[0];
        gvDamageItems.ShowEditor();
    }));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM