View previous topic :: View next topic |
Author |
Message |
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Wed Jul 16, 2008 12:25 pm Post subject: CTRL+A when row editing |
|
|
I'd like to make CTRL+A select all text when there is an active editor (Textbox or universalEditBox) in a row. How can I do this?
I read this post:
http://www.infralution.com/phpBB2/viewtopic.php?t=962&highlight=processcmdkey
and noticed there is something like ProcessEditCmdKey (for handling key events when there is an active editor). I think I need this, but is there an example? I can't find out how to get the active editor and select the text.
Thanks a lot,
Anja |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jul 16, 2008 11:15 pm Post subject: |
|
|
Yes you will need to override the ProcessEditCmdKeys method something like:
Code: | protected overrides bool ProcessEditCmdKeys(Keys keys)
{
if (keys == Keys.Control | Keys.A)
{
SelectAllRows();
}
return base.ProcessEditCmdKeys(keys);
} |
Note that the reason Virtual Tree doesn't implement this behaviour by default is that there can be a significant performance (and memory) penalty when selecting all rows. This is because this forces Virtual Tree to load the data for all the currently expanded rows. If you have a very large number of rows in any given level (eg 100000 rows beneath the root row) then this could take considerable time. _________________ Infralution Support |
|
Back to top |
|
|
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Thu Jul 17, 2008 6:27 pm Post subject: |
|
|
Well, this is not exactly what I meant. I'd like to select the text (all the words) which has been entered in a textbox cell in the tree, not all rows in the tree. So when I override the ProcessEditCmdKeys method, how can I detect which cell is being editted and how can I get to the textbox to select the text, when it is in edit mode? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Jul 17, 2008 11:12 pm Post subject: |
|
|
Sorry I misunderstood you. The problem is that the standard TextBox does not handle the Control-A combination. You can derive your own TextBox control that does as follows:
Code: | public class MyTextBox : TextBox
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.A | Keys.Control))
{
this.SelectAll();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
} |
You can then use this as your editor. _________________ Infralution Support |
|
Back to top |
|
|
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Mon Jul 21, 2008 2:19 pm Post subject: |
|
|
Yes, that's what I was looking for. Is it also possible to do something similar with a UniversalEditBox instead of a TextBox? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jul 21, 2008 10:31 pm Post subject: |
|
|
Yes but to select the text you have to call the internal TextBox property eg
Code: | public class MyUniversalEditBox : UniversalEditBox
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.A | Keys.Control))
{
this.TextBox.SelectAll();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
} |
_________________ Infralution Support |
|
Back to top |
|
|
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Tue Jul 22, 2008 8:25 am Post subject: |
|
|
Thank you very much, great support again! |
|
Back to top |
|
|
Advansys
Joined: 27 May 2011 Posts: 20
|
Posted: Mon May 26, 2014 8:28 am Post subject: |
|
|
Would you recommend this same approach to enable the Ctrl+Left and Ctrl+Right arrows?
Our objective is to have the textbox edit function in the same way as editing a file name in Windows File Explorer, i.e. being able to move the cursor by word, left or right.
If it is the same approach, how should we send the Ctrl+Left or Ctrl+Right to the textbox after we trap it using the keyData test?
We also want to have the Tab key save changes and exit edit mode.
Thank for any advice you can offer.
Regards,
Greg
Advansys |
|
Back to top |
|
|
Advansys
Joined: 27 May 2011 Posts: 20
|
|
Back to top |
|
|
|