How to capture multiple key pressed using keydown or keypress event in farpoint spread in c#?

301 Views Asked by At

Consider a Farpoint spread control containing multiple columns and rows. On Entering/Pressing multiple alphabetical keys,it should select the row which has entered combination of words.

Example:If 'a','n','u' is typed it should automatically select the row with name anusha. If 'j','a' is typed it should automatically select the row related to that combination(jack,jane,etc).

when I use the below code,value of keyChar is always single character(a,b,c,..).If I try typing 'a','n','u', the it is not displaying anusha. It is displaying some other name starting with a(ambi),then n(nisha) and then u(uma) in this order.This is because keypress event is called every single time a key is pressed. Now my concern is how to make keyChar accept strings?

private void Keypress(object sender,KeyPressEventArgs e)
{
    If(e.KeyChar != (char)Keys.Enter && e.KeyChar != (char)Keys.Escape)
    {
        ABCFunction.SpreadKeyAction(SftTaskTree, e.KeyChar.ToString(), Name_Col_Pos);
    }
}

I tried using variable to store and pause the thread for particular time. Even this is not working since everytime it enters the 'if' loop and makes the stored variable empty.

private void Keypress(object sender,KeyPressEventArgs e)
{
       store = store + e.KeyChar.ToString();
       Thread.Sleep(1500);
       If(e.KeyChar != (char)Keys.Enter && e.KeyChar != (char)Keys.Escape)
       {
          ABCFunction.SpreadKeyAction(SftTaskTree, store , Name_Col_Pos);
          store = String.Empty;
       }
}

Please anyone help with this...

0

There are 0 best solutions below