0

Let a user control A containing a button bA and a user control AChild inheriting from A and containing a TableLayoutPanel.

If I want the inherited button bA, within ChildA, not to be where it was placed within A, but instead be placed in ChildA's TableLayoutPanel, how can I do ?

I did change bA's visibility from private to protected, and it is not Locked. But still, when I moved the inherited button bA within ChildA, it can be moved as expected, but it can NOT be moved inside ChildA's TableLayoutPanel. It's like I could move bA around, but not change its parent within ChildA Why ? Any workaround ? Thank you.

Virus721
  • 8,061
  • 12
  • 67
  • 123

1 Answers1

0

The designer seems like doesn't support this kind of functionality, but you can do that programmatically if you want to.

In the constructor of your AChild control, you can simply add to the tableLayoutPanel1 the button:

    public partial class AChild: A
    {
        public AChild()
        {
            InitializeComponent();
            tableLayoutPanel1.Controls.Add(bA);
        }
    }
fruggiero
  • 943
  • 12
  • 20
  • Thanks for your help. I tried something similar using SetColumn(), but the change doesn't seem to appear in the designer. I don't know if the designer is only executing the code it has generated or the whole contructor... – Virus721 Apr 22 '16 at 13:04
  • This SO questions says that some controls du not support visual inheritance : http://stackoverflow.com/questions/207504/datagridview-locked-on-a-inherited-usercontrol. I guess it works the same for the TableLayoutPanel – Virus721 Apr 22 '16 at 13:07