<tfoot id='9sUk0'></tfoot>

      <small id='9sUk0'></small><noframes id='9sUk0'>

      <i id='9sUk0'><tr id='9sUk0'><dt id='9sUk0'><q id='9sUk0'><span id='9sUk0'><b id='9sUk0'><form id='9sUk0'><ins id='9sUk0'></ins><ul id='9sUk0'></ul><sub id='9sUk0'></sub></form><legend id='9sUk0'></legend><bdo id='9sUk0'><pre id='9sUk0'><center id='9sUk0'></center></pre></bdo></b><th id='9sUk0'></th></span></q></dt></tr></i><div id='9sUk0'><tfoot id='9sUk0'></tfoot><dl id='9sUk0'><fieldset id='9sUk0'></fieldset></dl></div>

        <legend id='9sUk0'><style id='9sUk0'><dir id='9sUk0'><q id='9sUk0'></q></dir></style></legend>
          <bdo id='9sUk0'></bdo><ul id='9sUk0'></ul>

      1. 可扩展的 WinForms 文本框

        时间:2023-06-08
            <tbody id='yDWKR'></tbody>
        • <i id='yDWKR'><tr id='yDWKR'><dt id='yDWKR'><q id='yDWKR'><span id='yDWKR'><b id='yDWKR'><form id='yDWKR'><ins id='yDWKR'></ins><ul id='yDWKR'></ul><sub id='yDWKR'></sub></form><legend id='yDWKR'></legend><bdo id='yDWKR'><pre id='yDWKR'><center id='yDWKR'></center></pre></bdo></b><th id='yDWKR'></th></span></q></dt></tr></i><div id='yDWKR'><tfoot id='yDWKR'></tfoot><dl id='yDWKR'><fieldset id='yDWKR'></fieldset></dl></div>
          • <bdo id='yDWKR'></bdo><ul id='yDWKR'></ul>

              • <tfoot id='yDWKR'></tfoot>

                <small id='yDWKR'></small><noframes id='yDWKR'>

              • <legend id='yDWKR'><style id='yDWKR'><dir id='yDWKR'><q id='yDWKR'></q></dir></style></legend>

                  本文介绍了可扩展的 WinForms 文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Windows 窗体应用程序中创建了一个文本框,该文本框从一个高度开始,用于在单行中输入文本.但是,如果用户输入包含在控件中的文本,我希望文本框自动增加其高度.

                  I have created a textbox in a Windows Forms application that starts out at a height for entering text in a single line. But I would like the textbox to automatically increase its height if the user enters text that is wrapped within the control.

                  目前,对于这个文本框,我将属性 multiline 和 wordwrap 设置为 true.我尝试使用 TextChanged 事件来确定文本何时被换行,但我找不到任何可以帮助我解决此问题的属性.Lines 属性不提供任何包装文本的帮助;仅适用于用户按回车键开始新行的文本.

                  Currently, for this textbox, I have the properties multiline and wordwrap set to true. I've tried using the TextChanged event to determine when the text has been wrapped but I'm unable to find any property that will help me with this. The Lines property does not provide any help with wrapped text; only for text that the user has hit enter to begin a new line.

                  如何让我的文本框在每次文本换行超过文本框宽度时扩展其高度?

                  How can I get my textbox to expand its height each time the text wraps past the width of the textbox?

                  推荐答案

                  与其他人发布的想法相同,将其放入您的 textChanged 事件中:

                  Same kind of idea as others have posted, put this in your textChanged event:

                  Dim s As SizeF = TextRenderer.MeasureText(txt.Text, txt.Font, txt.ClientRectangle.Size, TextFormatFlags.WordBreak)
                  txt.Height = CInt(s.Height)
                  

                  您将需要某种最小高度,并且可能需要指定一些填充,但这确实有效.

                  You will need some kind of minimum height, and possibly to specify some padding, but this does work.

                  这篇关于可扩展的 WinForms 文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:WPF 中 TextBox 中的 ScrollToCaret 在哪里? 下一篇:.Net TextBox 具有自动完成和自定义排序(不按字母顺序)

                  相关文章

                  <tfoot id='V8vGG'></tfoot>

                      <small id='V8vGG'></small><noframes id='V8vGG'>

                    1. <legend id='V8vGG'><style id='V8vGG'><dir id='V8vGG'><q id='V8vGG'></q></dir></style></legend>
                    2. <i id='V8vGG'><tr id='V8vGG'><dt id='V8vGG'><q id='V8vGG'><span id='V8vGG'><b id='V8vGG'><form id='V8vGG'><ins id='V8vGG'></ins><ul id='V8vGG'></ul><sub id='V8vGG'></sub></form><legend id='V8vGG'></legend><bdo id='V8vGG'><pre id='V8vGG'><center id='V8vGG'></center></pre></bdo></b><th id='V8vGG'></th></span></q></dt></tr></i><div id='V8vGG'><tfoot id='V8vGG'></tfoot><dl id='V8vGG'><fieldset id='V8vGG'></fieldset></dl></div>
                        <bdo id='V8vGG'></bdo><ul id='V8vGG'></ul>