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
3555
Global Class for KeyPress not working correcly
posted
When I press the arrow keys it seems to skip a cell. I created a public
static void class to put the keydown code in since all of my grids in all of
my forms needs this behavior. Anyone know why it would skip a cell when I
hit the arrow keys?



Btw, I set the KeyDown event in the InitializeLayout of the grid



this.ultraGridTreatedDays.KeyDown += UltraWinGridBehavior.KeyDown;





using System;

using System.Collections.Generic;

using System.Text;

using Infragistics.Win.UltraWinGrid;

using System.Windows.Forms;

using Infragistics.Win;



namespace MarketForecaster.BOL

{

public class UltraWinGridBehavior

{



public static void KeyDown(object sender, KeyEventArgs e)

{

UltraGrid grid = sender as UltraGrid;



switch (e.KeyValue)

{



case (int)Keys.Up:



grid.PerformAction(UltraGridAction.ExitEditMode, false,
false);

grid.PerformAction(UltraGridAction.AboveCell, false,
false);

e.Handled = true;

grid.PerformAction(UltraGridAction.EnterEditMode, false,
false);

break;



case (int)Keys.Down:



grid.PerformAction(UltraGridAction.ExitEditMode, false,
false);

grid.PerformAction(UltraGridAction.BelowCell, false,
false);

e.Handled = true;

grid.PerformAction(UltraGridAction.EnterEditMode, false,
false);

break;



case (int)Keys.Right:



grid.PerformAction(UltraGridAction.ExitEditMode, false,
false);

grid.PerformAction(UltraGridAction.NextCellByTab, false,
false);

e.Handled = true;

grid.PerformAction(UltraGridAction.EnterEditMode, false,
false);

break;



case (int)Keys.Left:



grid.PerformAction(UltraGridAction.ExitEditMode, false,
false);

grid.PerformAction(UltraGridAction.PrevCellByTab, false,
false);

e.Handled = true;

grid.PerformAction(UltraGridAction.EnterEditMode, false,
false);

break;

}



}



}

}