This is the discussion forum for the HtmlEditor. See also the
HtmlEditor home page, where you can download the control, and the
Documentation Wiki, a collaborative project for documenting the control.
Selecting an element failed when the cursor is on free text (on the body)
Posted by:
liorklain (---.cust.bezeqint.net)
Date: Sunday, 15-Oct-2006, 17:39:30
I use external list of my objects (Html Elements) to select html elements in
the htmleditor, when other element selected already i successed but when a text is selected this code is failed:
HtmlSelection selection = this.Document.selection;
HtmlControlRange range;
try
{
// get selection range
range = (HtmlControlRange)selection.createRange();
// if item is already selected return from selection
if ((range != null) && (range.length > 0))
{
if (range.item(0) == htmlElement)
{
return;
}
}
// clear all selected items
while (range.length > 0)
{
range.remove(0);
}
// add selected element to the range of selection
range.add(htmlElement as IHTMLControlElement);
// set the range to be selected
range.select();
range.scrollIntoView(null);
}
catch (Exception ex)
{
Debug.Write(ex.Message);
}
can somebody help me?
thank you, lior