icon change on Ctrl-I

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Nassim Farhat
Version: 4.0.0276
Avatar
Hello

I need my editor to open a dialog when I click on ctrl-I, but everytime I do so it changes the icon to a predifined keyword icon used for the CTRL-I sequence.... (some sort of find icon with and an arrow pointing down)

I have no problem opening my dialog and capturing the control-I, but how to I reset the icon to the original one everytime my dialog opens, so that when I close my dialog I can comeback to my original icon and not have this weird looking icon anymore?

Thanks in advance.

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That is the incremental search feature kicking in. You'd have to remove the command binding for Ctrl+I from the SyntaxEditor control.

Take a look at the Commands QuickStart since that shows how to iterate SyntaxEditor.CommandLinks. You'd want to do that and look for one with a KeyBinding of Ctrl+I, then remove that. Probably the Shift+Ctrl+I one too, which is reverse incremental search.

Note this feature only kicks in when the editor has focus.


Actipro Software Support

Posted 15 years ago by Nassim Farhat
Avatar
Thanks for your reply,

I tried what you told me but I always get an exception thrown when I try to remove the command "Ctrl-I".

Here is my code:

CommandLinkCollection cmdcollection = this.STsyntaxEditor.CommandLinks;
foreach (CommandLink cl in cmdcollection)
{
  if (cl.KeyBinding.Modifiers == ActiproSoftware.WinUICore.Input.ModifierKeys.Control &&
      cl.KeyBinding.Key == Keys.I)
  {
     cmdcollection.Remove(cl);
  }

}
I had to place a try/catch block so that my editor could open up. In any case, I would like to know what I'm doing wrong. The exception message I get is:
"Collection was modified; enumeration operation may not execute."

Thank you for your time
Nassim
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Nassim,

You can never in .NET remove an item in which you are doing a foreach loop through its collection. Doing that will always throw an exception, in any .NET context. You have to do a for loop instead from Count-1 down to 0 and remove by index instead.


Actipro Software Support

Posted 15 years ago by Nassim Farhat
Avatar
wow, you're right! I never had to perform a remove operation on a collection before! Well, like you said I indexed the whole thing in a forloop and bada boum... the remove worked!

Thank you for your great knowledge and hints.

Regards
Nassim
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.