Adding property to child controls

128 views Asked by At

If you have a container in .Net, is it possible to add a property to any children that are added to that control?

TableLayoutPanel appears to do this, if you add a control, say a a panel, the control has new properties, cell, column, row, colSpan, RowSpan. If you move the Control to another panel, or just outside the TableLayoutPanel the properties go away.

How is this achieved?

1

There are 1 answers

1
J.Hudler On BEST ANSWER

The TableLayoutPanel control implements the IExtenderProvider interface, and add ProvideProperty attributes with the names you mentioned above - resulting in this "additional properties feature" you inquired.

I would recommend you to dig its original source code to get more info about this implementation.

(If you don't have a .NET Disassembler, you may get a good and free one here.)

Some sources to get started with IExtenderProvider: