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. Image for the cookie policy date

GDBD CommandStack

Hi,

How can I disable Shortcuk Keys (ALT+Z) in GDBG.
I set
this.Model.CommandStack.Enabled = false;

but wheen I press ALT+Z redo i generated.

Best regards,
MS

9 Replies

AD Administrator Syncfusion Team August 3, 2006 07:02 PM UTC

Try handling the CurrentCellKeyDown event to see if that does what you need.

void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if((e.Alt && e.KeyCode == Keys.Z)
|| (e.Control && e.KeyCode == Keys.Z))
{
e.Handled = true;
}
}


MS Marek Solarski August 3, 2006 10:23 PM UTC

Hi,

Thank you for your answer.

I forgot to add that in my country RIGHT ALT + Z is a combination for a special character. I''d like this combination to put this special character in grida and not to generate undo/redo commands.

Regards,
MS


AD Administrator Syncfusion Team August 4, 2006 09:09 AM UTC

Hi Marek,

You can handle the CurrentCellKeyDown event and try to put the special character there itself. Try the code below.

void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if((e.Alt && e.KeyCode == Keys.Z) || (e.Control && e.KeyCode == Keys.Z))
{
string str = cc.Renderer.ControlText;
cc.Renderer.ControlText = str + "spl-char";
e.Handled = true;
}
}

Let us know if this helps.
Thanks,
Rajagopal


MS Marek Solarski August 4, 2006 01:58 PM UTC

Hi,
I tried your code.

cc.Renderer.ControlText is correct and contains special character.
But GDBG seems to catch the undo command anyway (although I set e.Handled = true) and any of my changes to cell value is being undone (rolled back by undo command) :(

Regards,
ms


MS Marek Solarski August 4, 2006 02:00 PM UTC

PS

Maybe I should handle

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {}

But I can''t figure out how to check whether ALT+Z was pressed.


AD Administrator Syncfusion Team August 7, 2006 06:12 AM UTC

Hi Marek,

Please try the below piece of code.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(this.gridDataBoundGrid1.CurrentCell != null)
{
if((Control.ModifierKeys & Keys.Alt) != 0)
{
if ((keyData & Keys.Z) == Keys.Z)
{
Console.WriteLine("Hello");
return true;
}
}
}
return base.ProcessCmdKey (ref msg, keyData);
}

Let me know if you need any further assistance.
Thanks,
Rajagopal


AD Administrator Syncfusion Team August 7, 2006 09:07 AM UTC

Hi,

Thank you - it works! However cell contents becames highlighted.

Could you please tell me how to make grid not to highlight the cell contents after I press ALT+Z

I replaced your line:
Console.WriteLine("Hello");

with

GDBD.CurrentCell.Renderer.ControlText += "spec-ch";

Regards,
Marek


AD Administrator Syncfusion Team August 7, 2006 09:31 AM UTC

Hi Marek,

Try adding the code below, this will help you.

///
this.gridDataBoundGrid1.CurrentCell.Renderer.ControlText += "spec-ch";

GridTextBoxCellRenderer tr = this.gridDataBoundGrid1.CurrentCell.Renderer as GridTextBoxCellRenderer;
tr.TextBox.SelectionStart = this.gridDataBoundGrid1.CurrentCell.Renderer.ControlText.Length;
tr.TextBox.SelectionLength = 0;
////

Regards,
Rajagopal


AD Administrator Syncfusion Team August 7, 2006 11:33 AM UTC

Thank you, it works!

Loader.
Live Chat Icon For mobile
Up arrow icon