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";
}
}