Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
focus to another grid in AfterExitMode
posted

I am trying to for focus over to another grid on a Winform, my code below get hit but I can't seem to escape the clutches of the current grid.  The code to focus gets hit, but I still in the igDet grid.  I've tried a dozen variations, all result in the cursor in the current grid igDet.  The grids are in a panel.  I also have tried the beforeRowInsert as well, grid will not lose it's death grip.  After 4 hours of random tries, I I would really love to move on the implementing the business rule itself instead of fighting control behavior (sigh)...Help me Obi Wan Kanobi!

 

     private void igDet_AfterExitEditMode(object sender, EventArgs e)

        {

             if (this.IsInBaseAction == false )

            {

                if ((string)igDet.ActiveCell.Column.Key == "bdsection")

                    {

                        int TotalQty;

                        TotalQty = moData.Details.Query("1=1").Aggregate<int>("bdqty", AggregateType.Sum).Coalesce(0);

                        if (TotalQty == moData.CurrentBomMast.BmQty)

                        {

                            this.tscMain.ActiveControl = igAlloc;

                            igAlloc.Focus();

                            this.igAlloc.ActiveRow = this.igAlloc.Rows[0];

                            this.igAlloc.ActiveCell = this.igAlloc.Rows[0].Cells["BaQty"];

                            this.igAlloc.PerformAction(UltraGridAction.EnterEditMode, false, false);

                        }

                    }

            }

        }

And this don't work either:

       private void igDet_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)

        {

            int TotalQty;

            TotalQty = moData.Details.Query("1=1").Aggregate<int>("bdqty", AggregateType.Sum).Coalesce(0);

            if (TotalQty == moData.CurrentBomMast.BmQty)

            {

                this.SelectNextControl(igDet, true, true, false, false);

            }

 

  • 469350
    Offline posted

    Hi,

    Just to add to what Brian posted, using AfterExitEditMode for this seems like a very odd choice. The cell can exit edit mode for a wide variety of reasons. For example, suppose the user edits a cell and then clicks on some other control on the form, like a Button. The button will get clicked and then focus will shift away from the button to another grid.

    Or... suppose they click on the second grid. You will end up ripping focus away from whatever cell they clicked on and putting it somewhere else.

  • 69832
    Offline posted

    Quite a few things happen when you exit edit mode on a cell, even after the AfterExitEditMode event fires. What you might want to try is moving the code you have in the AfterExitEditMode handler to an external method, then calling that method asynchronously in response to AfterExitEditMode using the BeginInvoke method. This will allow the whole process of exiting edit mode to complete before you take the focus away from the first grid.