Skip to main content

Custom Control - button being added twice RRS feed

  • Question

  • Hi,

    I've made a custom control, which is based off a text box (a third party text box - Infragistics). In the constructor of the custom control, I'm adding a button control.

    The control works fine - I can put it on a form, and run it, and it does everything I want it to.


    If I move the control now, it will add a button to the control in the designer (as per the controls constructor), adding the code to the form.Designer.cs file. Then when I try to run, it will try to add the button twice (once via the form, and once within the buttons constructor). It errors, as it can have two buttons with the same name.

    Whats going on here? Why is the form trying to do something (add a button) that the control will do fine for itself?


    Monday, March 7, 2016 12:20 AM