Auto-Expanding Controls/Textbox? RRS feed

  • Question

  • I've been trying for awhile now to add a feature to a UserControl i've been working on. The UserControl contains one control akin to a TextBox, And upon entering enough content into it, I want it to expand to show all the content instead of showing scrollbars.

    I can't, For the life of me, Get the UserControl to grow properly when the above happens. What's More, I have no idea where the UserControl will be used, So i don't want to count on what contains it, etc.

    A typical example would be a Form that contains a TableLayout/Splitter/Panels, And N instances of my UserControl inside those.

    Any suggestions or help regarding this issue will be greatly appreciated, I've tried just about anything i can think of right now.

    Tuesday, April 21, 2009 4:23 PM


All replies

  • So you can get it to grow, but not "properly".  What does that mean?  Controls that grow themselves are pretty hard to use.  Forcing the container to grow itself and causing a cascade of layout problems.  At least raise an event that the container can respond to or ignore.
    Hans Passant.
    Tuesday, April 21, 2009 5:45 PM
  • http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic34339.aspx  Seems to have some cool solution to resize richtextbox based on content. I guess u can expand to resize ur usercontrol.
    • Proposed as answer by Kira Qian Thursday, April 23, 2009 3:53 AM
    • Marked as answer by Kira Qian Tuesday, April 28, 2009 4:52 AM
    Wednesday, April 22, 2009 5:29 AM
  • it seems that the textbox is multiline. you can write it the way so that the height of the textbox increases by the amount of a certain value (say height value of a single-line textbox) each time a new line is added, but this could be complex depending on you form.

    Wednesday, April 22, 2009 6:51 AM