How to change "area" of a control in DesignMode?

Posted by Tronex on Stack Overflow See other posts from Stack Overflow or by Tronex
Published on 2010-05-19T07:56:48Z Indexed on 2010/05/19 8:00 UTC
Read the original article Hit count: 172

Filed under:
|
|

When I drag and drop a TextBox from the toolbox onto a WinForm, I can drag it around on the form as I like.

Now I create a new class and inherit it from TextBox. I add a new property called CaptionLabel. When set to a value, I dynamically create a Label control, set its value and finally add the label to the TextBox' parent controlcollection.

The result is a "LabeledTextBox".

However, when selecting the TextBox, I still only get the TextBox selected... the selection rectangle does not include the Label, created dynamically.

How do I extend the rectangle so that it also contains the Label and make the label "know" that it belongs to the TextBox?

Or is there a better way to create labeled controls?

© Stack Overflow or respective owner

Related posts about label

Related posts about controls