Custom Accelrator

Hello I would like to provide the user with custom Accelerators on the grid like CTRL+1 will Hide/show the first column I don''t know how...

1 Reply

AD Administrator Syncfusion Team April 11, 2005 07:00 PM UTC

There are 2 possible situations you may have to handle. One is when you want to catch ctl+1 when there is no actively editing cell in the grid. In this case, you can try handling the grid.KeyDown event. The second case is when you want to catch ctl+1 where there is an actively editing cell in teh grid. In this case, you can try handling the grid.CurrentCellControlKeyMessage event. Here are a couple of sample handlers.
private void gridControl1_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e)
{
	Keys keyCode = (Keys) ((int)e.Msg.WParam) & Keys.KeyCode;
	if(e.Msg.Msg == 256) // WM_KEYDOWN
	{
		if(keyCode == Keys.D1 && (Control.ModifierKeys & Keys.Control)!= 0)
		{
			MessageBox.Show("ctl+1");
			e.Handled = true;
			e.Result = false;
		}
	}
}
private void gridControl1_KeyDown(object sender, KeyEventArgs e)
{
	if(e.KeyCode == Keys.D1 && (Control.ModifierKeys & Keys.Control)!= 0)
	{
		MessageBox.Show("ctl+1");
		e.Handled = true;
	}
}

Loader.
Up arrow icon