Get all controls of the current form at design-time

前端 未结 4 674
陌清茗
陌清茗 2021-01-25 14:43

I have a question about design-time things:

I\'ve made a component with an property \"Links\". Those links are Controls. Now I want to make a UI-Dialog (for editing this

4条回答
  •  猫巷女王i
    2021-01-25 15:33

    This is quite untrivial to do, I don't know of any examples of .NET components that do this. You can get to the form at design time with the Site property but there are problems. What's hard to deal with is the user deleting controls, ones that you have already added to your controls collection. I don't know of any good trigger to keep your collection valid, beyond also having to use a custom designer for the form or user control.

    There's a better mousetrap for this, you see it being used by the HelpProvider and ErrorProvider components for example. Note how they add properties to all other controls on the form. This is done by implementing the IExtenderProvider interface. There's an excellent example of this in the MSDN library article.

提交回复
热议问题