views:

9

answers:

1

I'm having a user control (referred to as 'parent') which dynamically adds or removes other controls ('child').

The parent maintains a HelpProvider object that is supposed to be queried for help strings associated which controls contained in child ('subchild'). The subchild controls are not accessible directly, so I am planning to provide child with some method for letting child populate the HelpProvider object (e.g. public void InstallHelpProvider(HelpProvider)). So, when child is dynamically added to parent, parent will call InstallHelpProvider on the child before installing the control.

I am not fully aware of the HelpProvider internals, but I guess it will maintain a map for the controls being installed. Accordingly, I would like to remove entries from the parent's help provider when a child control is removed from parent (and if it's just for the sake of not wasting system ressources).

HelpProvider has a public method ResetShowHelp(Control) which I assume to do the job. However, MSDN says that this method is infrastructure and not inteded to be used directly.

Did anyone use this method anyway? Or maybe there is another (intended) way how to do this? Or maybe HelpProvider does not work well with my design?

Regards, jerb

A: 

Installing help on a control is done like this (you know it already):

    this.helpProvider1.SetShowHelp(this.cityTextBox, true);
    this.helpProvider1.SetHelpString(this.cityTextBox, "Enter the city here.");

Removing help is done the opposite way:

    this.helpProvider1.SetShowHelp(this.cityTextBox, false;
    this.helpProvider1.SetHelpString(this.cityTextBox, null);

I don't remember if both calls are necessary or if the first one is enough.

Timores
Ok, I could have guessed myself, since the Remarks section of HelpProvider.SetHelpKeyword says so (for SetHelpKeyword, though). Just out of interest: Where do you have this from? It's just that I did not find any simple way of testing setting a value null really removes the entry...
Jerb
As you wrote, the HelpProvider (and other extension classes like the Tooltip provider) maintain a map relating a control to the new data. I think I had learned how to remove a tooltip by such a construct (associating null with the control).
Timores