I am trying to create a custom control that inherits from the TextBoxTool. When I override the Method OnToolValueChanged to create some custom logic and add to the control it never fires. I can see that the control gets Instatiated with my inheriting class but when I put breakpoints in any of the overriden methods it never gets to them. Here is how I'm instantiating the class
public class ADACTextBoxTool : TextBoxTool
{
//public delegate void ProcessToolValueChanged(object sender, ToolEventArgs e);
}
and the overridden function that will not run.
_acListBox.Items.Clear();
_acListBox.Invalidate();
else
My question is am I missing an interface that needs to be implimented or am I missing a setting in the control that needs to enable this? Any help is greatly appriciated.
Nic
It sounds like your tool is being cloned internally, but the TextBoxTool's implementation of Clone is being used, so a new instance of TextBoxTool is being created. Overriding the Clone method should fix your issue. Try using the following code:
protected override ToolBase Clone(bool cloneNewInstance){ ADACTextBoxTool newTool = new ADACTextBoxTool( this.Key ); newTool.InitializeFrom(this, cloneNewInstance); return newTool;}
Also, if you define any member variables in your derived tool and cloned tools should have those values copied over, you should also override InitializeFrom:
protected override void InitializeFrom(ToolBase sourceTool, bool cloneNewInstance){ base.InitializeFrom(sourceTool, cloneNewInstance);
ADACTextBoxTool sourceTextBoxTool = sourceTool as ADACTextBoxTool;
if ( sourceTextBoxTool == null ) return;
// Copy member variable values here this.member1 = sourceTextBoxTool.member1;}
That did IT!!!! WOW thanks sooo much I was pulling my hair out all weekend trying to figure out why it wasen't working.