How Can a Textbox Be Dynamically Resized with the Form?

  • Thread starter Thread starter CodeMonkey
  • Start date Start date
  • Tags Tags
    Forms
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
CodeMonkey
Messages
11
Reaction score
0
I searched Google and could not find a solution for this.

I have a form with a text box and I want to make it so that when I resize the form while the application is running the text box would get resized as well and be "relative" to the size of the form.

Any help please?
 
Physics news on Phys.org
CodeMonkey, I think what you want to do is set the Anchor property of your text field. This is a property of all Controls:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.anchor.aspx

Assuming this is C#, I think you want to say
yourtextbox.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
 
Coin, thanks, that worked. :-)