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
163
Cell Navigation - stopping at First and Last Cell in Row
posted

When navigating through cells in UltraGrid, the left and right arrow keys move to previous and next cell respectively. When in the last cell in a row, the right key navigates to the first cell in the next row similarly when in the first cell in a row, the left key navigates to the last cell int the previous row.

I want to change this functionality and need the grid to remain in the Last Cell in the Row when on Last Cell in Row pressed Right Arrow Key, similarly, to remain in the First Cell in teh Row when on First Cell pressed Left Arrow Key. Secondly I want this operation to perform, when the Grid is not in Edit Mode.

I tried this through KeyActionMappings in Initialize Layout like:

resultsGrid.KeyActionMappings.Add(new GridKeyActionMapping(Keys.Right , UltraGridAction.LastCellInRow ,UltraGridState.InEdit , 0, 0 , 0));

but this navigates to the Last Cell in the Next Row, some how I am not able to figure out how to check if the Grid active cell was the last one in the current row and stop there. Is there any way to achieve this?

 

Due Regards,

Talha Muhammad

  • 163
    posted

     I fixed this issue by picking up the idea from another post at the location below:

    http://forums.infragistics.com/forums/p/7627/31045.aspx#31045

     

    the code is below if it could be of help for anyone other looking for such a thing:

    <Code>

    private void MyGrid_BeforePerformAction(object sender , BeforeUltraGridPerformActionEventArgs e)
            {
                if (MyGrid.ActiveCell != null)
                {
                    if (MyGrid.ActiveCell.Column.Index == 0)
                    {
                        if (e.UltraGridAction == UltraGridAction.PrevCell || e.UltraGridAction == UltraGridAction.PrevCellByTab)
                        {
                            e.Cancel = true;
                        }
                    }
                    else if (MyGrid.ActiveCell.Column.Index == MyGrid.DisplayLayout.Bands[0].Columns.Count - 1)
                    {
                        if (e.UltraGridAction == UltraGridAction.NextCell || e.UltraGridAction == UltraGridAction.NextCellByTab)
                        {
                            e.Cancel = true;
                        }
                    }
                }
            }

    </Code> 

     but if anyone has a better and simpler idea, do share that...

    Regards,

    Talha Muhammad