View previous topic :: View next topic |
Author |
Message |
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Wed Nov 05, 2008 4:34 pm Post subject: Get selected text when editing |
|
|
In my treeview a textbox is used as a cell editor. When I press F2 editing is started for this cell and I can change the text, and also select a part of the text. Is there a way to get this selected text during editing?
I'd like to show a search-form when Ctrl-F is pressed during editing, and fill in the selected text, so that I can search for this text through the whole tree. I know which cell (row and column) is selected, but how can I get the selected part of the text when this cell is being edited?
Thanks,
Anja |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Nov 05, 2008 9:22 pm Post subject: |
|
|
With the latest version (3.11.0) you can do the following:
Code: | private string GetSelectedText()
{
string text = null;
CellWidget editWidget = _virtualTree.EditWidget;
if (editWidget != null)
{
TextBox textBox = editWidget.EditorControl as TextBox;
if (textBox != null)
{
text = textBox.SelectedText;
}
}
return text;
} |
Note that the EditWidget property was only made public in 3.11.0. Previously it was protected - for earlier versions you could derive a new class from VirtualTree and add this function as a member method. _________________ Infralution Support |
|
Back to top |
|
|
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Mon Nov 17, 2008 9:43 am Post subject: |
|
|
I tried the new version and it works fine. Thanks a lot for your support.
Anja |
|
Back to top |
|
|
|