I want to have special keys that behave like macros or keying shortcuts that change the controltext of the current cell. For example, I''m handling CurrentCellKeyDown, and when I receive a "[" or "]" I need to rewrite the contents of the cell based on a certain calculation. I do that succesfully by setting CurrentCell.Renderer.ControlText and setting the event.Handled = true, but in the UI I end up in edit-mode with my editing text set as "]". If I ESC at that point it reverts to the value I wrote into CurrentCell.Renderer.ControlText, but how do I totally get rid of anything that thinks the current editing state is "]" (or "[")?
AD
Administrator
Syncfusion Team
August 31, 2005 07:12 PM UTC
You can try casting grid.CurrentCell.Renderer to a GridTextBoxCellRenderer, call it cr. Then you can try setting cr.TextBox.Text to be the string you want to see in the editing cell.
KO
Ken Overton
August 31, 2005 07:43 PM UTC
When I try that I briefly see the new value that I''m writing, then the state drops into editing mode with contents "]".
The final behavior I''m aiming for, btw, is to keep the cell activated and editing and allow the user to enter "]" or "[" as many times as they want, seeing the values change as I compute them. Then when they see a value they want, then they hit "return" and I do something different.
AD
Administrator
Syncfusion Team
August 31, 2005 10:03 PM UTC
Here is a little sample using CurrentCellValidateString.
http://www.syncfusion.com/Support/user/uploads/GC_77fdff7d.zip
If you type a open bracket, [, it will auatomatically add ''abcd'' after the bracket.
KO
Ken Overton
September 1, 2005 03:00 PM UTC
Very cool! ..... but .... unfortunately doesn''t work if you use arrow keys to reach a cell. I.e., if you''re not in edit mode, it doesn''t work. But I could use this if I could just find a way to force people into that mode when I want to (like when they''ve arrowed to a cell and started typing "["''s in it). Any way I can do that.
Unfortunately our users use the mouse about once an hour and do most navigation thru the keyboard.
AD
Administrator
Syncfusion Team
September 1, 2005 04:05 PM UTC
Try setting the grid.ActivateCurrentCellBehavior property to SetCurrent.
KO
Ken Overton
September 1, 2005 07:42 PM UTC
>Try setting the grid.ActivateCurrentCellBehavior property to SetCurrent.
Thanks again, for the suggestion. I don''t think that''s gonna be acceptable to the traders, as they can''t arrow right and left seamlessly from column to columnt with this setting; they end up arrowing through each and every character in each column.
AD
Administrator
Syncfusion Team
September 1, 2005 08:59 PM UTC
Try this. It worked for me without using teh SetCurrent setting.
private void gridControl1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
if(e.Text.EndsWith("["))
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if(!cc.IsEditing)
cc.BeginEdit();
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
cr.TextBox.Text = e.Text + "abcde";
cr.TextBox.SelectionLength = 0;
cr.TextBox.SelectionStart = cr.TextBox.Text.Length;
e.Cancel = true;
}
}
KO
Ken Overton
September 2, 2005 03:42 PM UTC
Yes! That does what I want, thanks a lot.