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

1.4k views Asked by At

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();
        }));
    }

enter image description here

Code to select other control after FormLoad()

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

There are 2 answers

0
Triple K On BEST ANSWER

Sorry for late reply. I got a soultion at there XtraGrid AutoFilterRow focusing

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();
    }));
}
0
jambonick On

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? 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

}