Thanks.
>Hi Hui,
Before setting the SelectionStart/Text property of the GridTextBox control, you should call the CurrentCell.BeginEdit method to start the editing mode of the current cell (it also allows setting the focus to the cell editor). Here is a code snippet to show this.
///Else part in the CurrentCellKeyPress event.
if (e.KeyChar != '-')
{
GridCurrentCell cc = gridControl1.CurrentCell;
if (!cc.IsEditing)
cc.BeginEdit(true);
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
if (cr != null && cr.TextBox.SelectionStart == 0)
{
cr.TextBox.Text = "-" + e.KeyChar;
cr.TextBox.SelectionStart = 2;
cr.TextBox.SelectionLength = 1;
e.Handled = true;
}
}
Please refer to the attached sample for implementation.
NegativeEntry.zipBest Regards,
Haneef