Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
UltraWinToolbar Inheritance and events.
posted

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);

 

public ADACTextBoxTool(string key): base(key)

{

 

}

 

and the overridden function that will not run.

protected override void OnToolValueChanged(ToolEventArgs e)

{

if (this.Text.Length >= 2 && _AutoCompleteSource == ShellAutoComplete.AutoCompleteFlags.ActiveDirectory)

{

_acListBox.Items.Clear();

_acListBox.Invalidate();

_acListBox.Items.AddRange(
ActiveDirectoryAutoComplete.GetAutoComplete(this.Text));_acListBox.Visible = true;

}

else

{

_acListBox.Visible =
false;

}

 

base.OnToolValueChanged(e);

}

 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

 

Parents
  • 44743
    Verified Answer
    posted

    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;
    }

Reply Children
No Data