This is a migrated thread and some comments may be shown as answers.

How call sth like commandCellClick when I press key on keyboard?

3 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew L
Top achievements
Rank 1
Andrew L asked on 30 Aug 2010, 02:05 PM
Hi,
I write GridBechaviour and I don't know how activate cellCommmand after KeyDown (in my code it is Space), that its possible ?
In example can be show a messagebox, after press space.
Andrew

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 02 Sep 2010, 11:26 AM
Hello Andrew L,

Thank you for contacting us. I am not sure that I understand your question. Please describe the desired behavior in greater detail. You can override the default grid behavior and handle the ProcessKey method. This way you can intercept when the user presses the Space key. If this is the case, please consider the code below:
this.radGridView1.GridBehavior = new CustomGridBehavior();
 
public class CustomGridBehavior : BaseGridBehavior
{
    public override bool ProcessKey(KeyEventArgs keys)
    {
        if (keys.KeyCode == Keys.Space)
        {
            MessageBox.Show("Hello world!");
            return true;
        }
        return base.ProcessKey(keys);
    }
}

I hope this helps.

Greetings, Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrew L
Top achievements
Rank 1
answered on 02 Sep 2010, 12:17 PM
Hello Jack ,

In code I have two different RadGridView, and one CustomGridBehaviour for this controls. Both of  RadGridView have CommandColumns. Every of columns doing something else, how can I activate that what is set to active CommandCollumn when I press Space ? Can I do that with GridBehaviour or maybe I must do thise for all RadGridView without GridBehaviur

Andrew L
0
Jack
Telerik team
answered on 07 Sep 2010, 09:52 AM
Hello Andrew L,

You cannot click the current command button by using the grid API. However, you can identify it by using the CurrentCell property: 

public override bool ProcessKey(KeyEventArgs keys)
{
    if (keys.KeyCode == Keys.Space)
    {
        GridCommandCellElement cell = GridControl.CurrentCell as GridCommandCellElement;
        if (cell != null)
        {
            //...
        }
        return true;
    }
    return base.ProcessKey(keys);
}

I hope this helps.

Kind regards,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Andrew L
Top achievements
Rank 1
Answers by
Jack
Telerik team
Andrew L
Top achievements
Rank 1
Share this question
or