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

need to move cursor within the cell

Hi,

I have a grid and a grouping control. For both of them there is a cell to enter a decimal number in a "#.0" format.
Is there a way to move cursor within the cell to another position?
For example:
Let’s say we have a value 11.4 in the cell. Then user types dot after the first “1”, i.e current value is getting “1.1.4” and at that moment I need to move cursor after the decimal point, i.e to have “11.(here is cursor)4”. If I just remove first dot or put some other logic to have correct value in the cell, it still keeps cursor at the position where user types the dot but not after the decimal point.
Another example, when user types the dot right before the decimal point. When I remove the dot, the cursor still stays before decimal point, but should stay after it.

Thanks in advance,
Irina

2 Replies

AD Administrator Syncfusion Team August 14, 2006 04:51 AM UTC

Hi Irina,

You can access the GridTextBoxCellRenderer and can move the cursor positioin using SelectionStart property of TextBoxCell. Here is a code snippet

private void gridl1_TableControlCurrentCellKeyPress(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyPressEventArgs e)
{
if( e.Inner.KeyChar == ''.'')
{
Console.WriteLine("Dot pressed");
e.Inner.Handled = true;
GridTextBoxCellRenderer render = e.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer;
if( render != null)
{
render.TextBox.SelectionStart = 3;
render.TextBox.SelectionLength = 0;
}
}
}

Let me know if this helps.
Regards,
Haneef


IJ Irina Jouk August 14, 2006 04:58 PM UTC

Thanks very much Haneef. It helped

Irina


Loader.
Live Chat Icon For mobile
Up arrow icon