Hello,
I am using a UltrWinGrid and I am having trouble with the cells in the Grid.
If I use arrow keys to navigate the cells. For some reason when I press any of the arrow keys the cell focus moves from right to left. Even if I press the down or up arrow key the behavior is to move from right to left across the screen. Once the row is completed then the focus shifts to the cells in the next row below I am not sure what is happening.
Other thing I noticed was that when I click on a cell in a row which is not editable and press the backspace the whole row turns Grey. Not sure why this is happening either.
Hoping for some help as i am still learning how to use UltraWinGrid and its functions.
Thanks,Ashwin
I have this code for tracking the key press event but for some reason it does not even get to this code when I run it in Debug mode
this.dgItems.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dgItems_KeyDown);
switch (e.KeyCode)
{
case Keys.Up:
dgItems.PerformAction(UltraGridAction.ExitEditMode, false, false);
int saveActiveCellIndex = dgItems.ActiveCell.Column.Index;
if (dgItems.ActiveRow.Index > 0)
dgItems.ActiveRow = dgItems.Rows[dgItems.ActiveRow.Index - 1];
dgItems.ActiveCell = dgItems.ActiveRow.Cells[saveActiveCellIndex];
}
e.Handled = true;
dgItems.PerformAction(UltraGridAction.EnterEditMode, false, false);
break;
case Keys.Down:
int saveActiveCellIndexs = dgItems.ActiveCell.Column.Index;
if (dgItems.ActiveRow.Index < dgItems.Rows.Count - 1)
dgItems.ActiveRow = dgItems.Rows[dgItems.ActiveRow.Index + 1];
dgItems.ActiveCell = dgItems.ActiveRow.Cells[saveActiveCellIndexs];
case Keys.Left:
dgItems.PerformAction(UltraGridAction.PrevCell, false, false);
case Keys.Right:
dgItems.PerformAction(UltraGridAction.NextCell, false, false);
Hi,
If the event is not firing (Debug mode or otherwise), then something is wrong. Are you sure you are hooking the event? Is it getting unhooked somewhere else in your code? Is there a toolbar or something on the form that might be eating the arrow keys?
Hello Mike,
I hook the event here
public StoreTransferView()
InitializeComponent();
I have attached and image of how and where the grid appears. ( Its in the middle below the "Add Items" Drop down button)
I also noticed that the event handler fires for any other key on the key board except for the arrow keys. And when I press the arrow key, although the event handler does not get called the selection moves from left to right.
Hoping for some help / suggestions
Thanks,
Ashwin
Hi Ashwin,
Well, if the KeyDown event is not firing just for those keys, but the active cell in the grid is changing, then it seems like the grid must be handling those keys before the KeyDown event gets called somehow and then the grid is not firing the event.
That should not happen. The grid should fire the KeyDown event and give you a chance to handle the key first. But without knowing all of the grid's property settings and the current state of the grid when this is occurring, it's impossible for me to try this out to see if it's a bug.
What version of the grid are you using?
Can you post a small sample project demonstrating this behavior?
Thanks for the reply Mike. I will post a simple project shortly.
Sorry about the delay in replying. I tired to put together a sample project but i kept getting a lot of errors.
I realized that we are using a custom grid that inherits from the ultragrid.
When I looked into code of custom grid, here is the method that gets fired when I press the down arrow key
private void OnDownArrowPressed(KeyEventArgs e)
//If Down arrow and DropDownIsNotActive
if (e.KeyCode == Keys.Down && !(_blnIsDropDownActive))
//If in EditMode, Exit the edit mode from current row
if ((_objUltraGrid.CurrentState & UltraGridState.InEdit) == UltraGridState.InEdit)
_objUltraGrid.PerformAction(UltraGridAction.ExitEditMode, false, false);
//If no active cell move to the row below.
if (_objUltraGrid.ActiveCell == null)
_objUltraGrid.PerformAction(UltraGridAction.BelowRow, false, false);
//If active cell, move to the cell below and enter edit mode.
else if (_objUltraGrid.ActiveCell != null)
_objUltraGrid.PerformAction(UltraGridAction.BelowCell, false, false);
_objUltraGrid.PerformAction(UltraGridAction.EnterEditMode, false, false);
This seems to work fine in other places where this is being used but when i try to use this in my project it does not seem to move down to the cell in the bottom row, but moves to its right cell.
Hoping for some help.
A code snippet like this is pretty tough to read and I don't think anything here is related to the problem, anyway. I doubt that the issue is caused by property settings on the grid, it's more likely to be some event you are handling or method you are overriding.
I'm a bit confused by what you mean by this:
ajagadish said:This seems to work fine in other places where this is being used but when i try to use this in my project it does not seem to move down to the cell in the bottom row, but moves to its right cell.
Are you saying that you are using the same derived grid control in both cases and it works in one case and not in another? Or are you saying that you copied the same code?
From where does the OnDownArrowPressed method get called? My best guess is that maybe you are overriding some methods on the grid and never calling the base implementation.
Hi Mike,
Thanks for the quick response. Yes the custom grid seems to work fine in other places but not here in this particular case. But I got it working without the using the custom grid using some of the code I found from your older post ( http://community.infragistics.com/forums/p/1710/256009.aspx#256009)
Now this is working I will probably look at using the custom grid in leisure :).
Again thank you very much for all your help. Very much appreciated.