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
close icon

Add text when a cell is in edit mode

I am trying to mimic the behaviour of Excel, especially the percentage cells. I want to know two things to accomplish this.

1) Is there any way to differentiate how the editing is initiated? the options are double click, key input, F2, BeginEdit() method, etc.

2) Is it possible to append text while cell is being editted. In my requirement, a percentage sign should be there when the cell gets into the edit mode



1 Reply

HA haneefm Syncfusion Team November 22, 2007 08:31 PM UTC

Hi,

1) Is there any way to differentiate how the editing is initiated? the options are double click, key input, F2, BeginEdit() method, etc.
>>>>>>>>>>>>>>>>>>>>>>>>>

Yes, Below are the codes that shows this task.

private bool b_MouseDown = false;
void gridControl1_MouseDown(object sender, MouseEventArgs e)
{
b_MouseDown = true;
}

void gridControl1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{

KeyStateInfo Keyinfo = KeyboardInfo.GetKeyState(Keys.F2);

if ( Keyinfo.IsPressed )
{
Console.WriteLine("BeginEdit is called using the F2 Key");
}
else if (b_MouseDown)
{
Console.WriteLine("BeginEdit is called using the MouseClickButton");
}
else
Console.WriteLine("BeginEdit is called using the method");

b_MouseDown = false;
}

Please refer to the attached sample for implementation.
GridFormulaCells.zip

2) Is it possible to append text while cell is being editted. In my requirement, a percentage sign should be there when the cell gets into the edit mode
>>>>>>>>>>>>>>>>>>>>>

Yes, you can do this by using the GetEditState and SetEditState method. Here is a codes:

object obj_EditState = this.gridControl1.CurrentCell.Renderer.GetEditState();
this.gridControl1.CurrentCell.Renderer.ControlText += "%";
this.gridControl1.CurrentCell.Renderer.SetEditState(obj_EditState);

Best regards,
Haneef


Loader.
Live Chat Icon For mobile
Up arrow icon