How Can a Textbox Be Dynamically Resized with the Form?

  • Thread starter Thread starter CodeMonkey
  • Start date Start date
  • Tags Tags
    Forms
AI Thread Summary
To achieve dynamic resizing of a text box relative to a form in a Windows application, setting the Anchor property of the text box is essential. This property allows the text box to maintain its position and size relative to the edges of the form when it is resized. In C#, this can be implemented by using the code: yourtextbox.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right). This solution effectively ensures that the text box adjusts its dimensions appropriately as the form is resized.
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?
 
Technology news on Phys.org
Obviously this is Windows (not Xterm)? Less obviously - what language are you coding in?
 
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. :-)
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top