I am using VB.Net to write an add-in. I'd like to keep the tool that I created selected even when the user attempts to select a different tool, and only deselect when my tool is clicked on again.

  • How are you implementing ITool.Deactivate? May 9, 2012 at 18:28
  • I haven't implemented it yet. I figured this would be the key to doing this, but I wasn't sure what to put inside the Deactivate method
    – Xoph
    May 9, 2012 at 18:30
  • When you say: "keep the tool that I created selected even when another tool is selected" do you really mean: "keep the tool that I created selected even when the user attempts to select a different tool"? May 9, 2012 at 19:08
  • Yes, that is what I meant
    – Xoph
    May 9, 2012 at 19:10
  • Sorry, your interpretation was not exactly correct, what I mean is that I would like to keep my tool active, even when the user selects another tool. When the user clicks on the tool again, it should the deactivate my tool.
    – Xoph
    May 9, 2012 at 20:44

1 Answer 1


If IApplication.currenttool is your custom tool, return false for ITool.Deactivate, and set IApplication.CurrentTool = null in ICommand.OnClick.

  • Setting it to null tells me to convert to DBNull.Value, but this gives me the warning "Runtime errors might occur when converting 'System.DBNull' to 'ESRI.ArcGIS.Framework.ICommandItem'"
    – Xoph
    May 9, 2012 at 20:14
  • @Xoph I forgot you're in VB.NET. Did you try Nothing instead of Null? May 9, 2012 at 20:26
  • Nothing works. I'm still hazy on where to set IApplication.CurrentTool = nothing? You say in ICommand.OnClick. Should this be a ReadOnly Property or how do I implement it?
    – Xoph
    May 9, 2012 at 20:36
  • Does this just prevent other tools from being activated?
    – blah238
    May 9, 2012 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.