title: How to auto center textbox inside user control, when user control is resized?
body: <p>This issue is concerning C# WinForms ... I have custom user control which basically has 3 things: A label, a text box, and a list box, all arranged vertically like this:</p>
  
  <p><img src="https://i.stack.imgur.com/AJYY2.png" alt="XXXXXXXXXXXXX"></p>
  
  <p>I have written a small Custom ControlDesigner class to prevent the user from changing the height of this user control at design time.</p>
  
  <p>I also have set the textbox and listbox to anchor to left/right locations, so that when the user changes the width of the user control, these two internal controls resize beautifully.</p>
  
  <p>I want to have the Label is the horizontal center as well, but anchoring that to left/right doesn't seem to work. I'm thinking I might have to written some sort of custom resize function inside the custom control designer class, which automatically places the label in the middle when the user control is resized ?</p>
  
  <p>Also note that I want to label to still remain in the center when the label text is changed.</p>
  
  <p>So how do I do this ?</p>
  
  <p>Here is my custom control designer class till now:</p>
  
  <pre><code>public class DropDownTextBoxDesigner : System.Windows.Forms.Design.ControlDesigner
      {
          public override SelectionRules SelectionRules
          {
              get
              {
                  SelectionRules retVal =
                        SelectionRules.Visible |
                        SelectionRules.Moveable |
                        SelectionRules.LeftSizeable |
                        SelectionRules.RightSizeable;
  
                  return retVal;
              }
          }
      }
  </code></pre>