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. :-)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top