Append text

I have a simple question for which I don't find the answer:

How to append text inside the essential grid in a specific cell ?

When we are typing a cell; how to get the cursor position ? How to append text at the cursor position ?

Thanks

Nazim YENIER

1 Reply

CB Clay Burch Syncfusion Team August 25, 2009 07:40 PM UTC

This task is not necessarily simple because the TextBox is only available as the cell is actively being edited. So, this code only applies to a TextBox CellType, and only if the cell is being actively edited.


GridCurrentCell cc = gridControl1.CurrentCell; // or this.gridDataControl1.Model.Views.First().CurrentCell;
GridCellTextBoxRenderer renderer = cc.Renderer as GridCellTextBoxRenderer;
if (renderer != null)
{
TextBox tb = renderer.CurrentCellUIElement as TextBox;
if (tb != null)
{
//set 'Apple' into the text
renderer.ControlText = "Apple";
//this code puts the cursor after the last 'p'
tb.SelectionStart = 3;
tb.SelectionLength = 0;
//insert 'xx' after last p
tb.SelectedText = "xx";
}
}

Loader.
Up arrow icon