We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Custom cell renderer and key events

Thread ID:

Created:

Updated:

Platform:

Replies:

47593 Aug 8,2006 03:54 PM Aug 9,2006 06:42 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 8, 2006 03:54 PM

I''m building my own cell renderer which hosts a specific type of control. I''ve noticed that if I press enter or the arrow keys while my control has focus, the grid will intercept the key press and do what it would normally do with it and my control never sees those keys. Normal keys work as expected, it''s just special keys like enter, arrows, escape, etc.

What do I have to do in my cell renderer to pass these key events onto my control and not have the grid see and use them.

Thanks.

Administrator [Syncfusion]
Replied On August 9, 2006 06:42 AM

Hi Amit,

Since Grid hosts your control inside the cell, it will use the keys navigation keys to move between the cells and will not pass on to the custom Control. So if the Control (CurrentCell) is in focus, then we need to programmatically do the required functions.

You can try setting the Grid.WantKeys flag to true in the ProcessKeyEventArgs override and revert it back to false in the Keyup event of the custom control, so that the key messages will not be processed by grid.
If you set WantKeys property of the grid to false, the grid will not process any keys like, TAB, arrow keys, Esc, etc.

protected override void OnInitialize(int rowIndex, int colIndex)
{
//
this.Control.KeyUp += new KeyEventHandler(Control_KeyUp);
}

protected override bool ProcessKeyEventArgs(ref System.Windows.Forms.Message m)
{
Keys keyCode = (Keys) ((int) m.WParam) & Keys.KeyCode;

if (m.Msg == 256 && keyCode == Keys.Tab)
{
this.Grid.WantKeys = true;
}
else
this.Grid.WantKeys = false;
//
}

void Control_KeyUp(object sender, KeyEventArgs e)
{
this.Grid.WantKeys = true;
}

Let me know if this helps.
Thanks,
Rajagopal

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;