Hello, Antti,
To work around this problem you can create a custom RadTextBoxControlEditor:
public RadForm1()
{
InitializeComponent();
this.radGridView1.EditorRequired += this.RadGridView1_EditorRequired;
}
private void RadGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
if (e.EditorType == typeof(RadTextBoxEditor))
{
e.Editor = new MyEditor();
}
}
public class MyEditor: RadTextBoxControlEditor
{
protected override RadElement CreateEditorElement()
{
return new MyRadControlEditorElement();
}
}
internal class MyRadControlEditorElement : RadTextBoxControlElement
{
protected override void CreateChildElements()
{
base.CreateChildElements();
this.Navigator = new MyTextBoxNavigator(this);
}
protected override TextBoxViewElement CreateViewElement()
{
return new MyTextBoxViewElement();
}
}
internal class MyTextBoxNavigator : TextBoxNavigator
{
public MyTextBoxNavigator(RadTextBoxControlElement textBoxElement) : base(textBoxElement)
{
}
public override bool Select(TextPosition start, TextPosition end)
{
if (start != null && start.TextBlock == null)
{
return false;
}
return base.Select(start, end);
}
public override TextPosition GetPositionFromOffset(int offset)
{
if (offset < 0)
{
throw new ArgumentOutOfRangeException("offset");
}
if (offset > this.TextBoxElement.TextLength)
{
offset = this.TextBoxElement.TextLength;
}
TextBoxViewElement layoutPanel = this.TextBoxElement.ViewElement;
LineInfo line = layoutPanel.Lines.BinarySearchByOffset(offset);
if (line == null)
{
return null;
}
ITextBlock textBlock = layoutPanel.BinarySearchTextBlockByOffset(line, offset);
int characterPosition = offset;
if (textBlock != null)
{
characterPosition -= textBlock.Offset;
}
TextPosition position = new TextPosition(line, textBlock, characterPosition);
return position;
}
}
internal class MyTextBoxViewElement : TextBoxViewElement
{
protected override ITextBlock BinarySearch(LineInfo line, IComparer comparer)
{
if (this.Children.Count == 0)
{
return null;
}
return base.BinarySearch(line, comparer);
}
}
I hope this helps.
Regards,
Nadya
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.