[WinForms].I have 3 columns in a gridview - code,Qty,name.If a cell(Say Code), is in edit mode, pressing the arrow or tab keys will fire the 'CellEndEdit' event and after that,moves the selection to the next cell. I want to have different selected cell if it is an arrow key and another selected if it is tab. eg:
On Right arrow key: Code -> Qty
On Tab press: Code -> Name

The datagridview's key events(down,up,press) dont fire once the cell enters edit mode.So, how can i get the last pressed key's value when the cell is in edit mode. I have to write the code/method/function in CellEndEdit event. Can this be something like:

private void DataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) 
{
  //Some calculations;
  //Get the key if it is tab or arrow to decide which cell should be selected next
  If((bool)OnKeyDown()==true)
     then do this;
}          
void OnKeyDown(KeyEventArgs e)
{
  if(e.KeyValue==9)//tab key
     return true;
}

please help

Edited 3 Years Ago by RubyRuby

I resolved it this way based on a soln. here:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0283fe97-c0ad-4768-8aff-cb4d14d48e15/

bool IsTabKey;
private void DataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)       
{  
   //Some calculations;  
  //Get the key if it is tab or arrow to decide which cell should be selected next  
    If(IsTabKey==true)   
      //then do this;
}  
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if(GridViewSale.CurrentCell.ColumnIndex == 1 && keyData == Keys.Tab)
       IsTabKey = true;
       return false;
}
This question has already been answered. Start a new discussion instead.