1. <legend id='TydLL'><style id='TydLL'><dir id='TydLL'><q id='TydLL'></q></dir></style></legend>
      2. <small id='TydLL'></small><noframes id='TydLL'>

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

        如何用默认文本填充空文本框?

        How do I fill an empty textbox with default text?(如何用默认文本填充空文本框?)
        <legend id='RmYXM'><style id='RmYXM'><dir id='RmYXM'><q id='RmYXM'></q></dir></style></legend>

        1. <small id='RmYXM'></small><noframes id='RmYXM'>

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

          • <tfoot id='RmYXM'></tfoot>
                <tbody id='RmYXM'></tbody>

                • <bdo id='RmYXM'></bdo><ul id='RmYXM'></ul>
                  本文介绍了如何用默认文本填充空文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果文本框为空,如何用文本填充?我正在使用 VB.NET.

                  How do I fill a textbox with text if it is empty? I am using VB.NET.

                  推荐答案

                  您似乎在描述一个 提示横幅,它是显示在空文本框中的提示文本.从 Windows XP 开始,操作系统本身就支持此功能.这样实现的效果比在 TextChanged 事件中自己设置默认文本要优雅得多.它看起来像这样:

                  It looks like you're describing a cue banner, which is prompt text that is displayed in an empty textbox. As of Windows XP, this functionality is natively supported by the operating system. The effect achieved doing it this way is much more elegant than setting the default text yourself in the TextChanged event. It looks like this:

                       

                       

                  通过向文本框控件发送 EM_SETCUEBANNER 消息.要在 .NET 项目中使用它,您必须使用 P/Invoke.

                  Setting this up is accomplished at the level of the Windows API by sending the textbox control an EM_SETCUEBANNER message. To use this from a .NET project, you will have to use P/Invoke.

                  幸运的是,大部分工作已经为您完成.这个示例项目是一种快速、轻松的方式来将提示横幅支持添加到现有项目.这里是另一个示例,对过程进行了更完整的说明.

                  Fortunately, most of the work has already been done for you. This sample project is a quick and painless way to add cue banner support to an existing project. Here's another sample, with a more complete explanation of the process.

                  如果您不希望您的应用程序依赖于外部 DLL,您可以将必要的代码直接添加到您的项目中.最简单的方法是继承现有的 TextBox 控件,并在其中添加支持提示横幅的代码.有关您需要的代码,请参阅此答案.如果您在将其转换为 VB.NET 时遇到问题,请尝试 此工具.

                  If you don't want your application to depend on an external DLL, you can add the necessary code directly to your project. The simplest way is to subclass the existing TextBox control, and add the code to support cue banners there. See this answer for the code you'll need. If you have trouble converting it to VB.NET, try this tool.

                  这篇关于如何用默认文本填充空文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                  Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                  C# - Add button click events using code(C# - 使用代码添加按钮单击事件)
                  Multi-color TextBox C#(多色文本框 C#)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                  C# .NET multiline TextBox with same-width characters(具有相同宽度字符的 C# .NET 多行文本框)

                        <tbody id='UJGBQ'></tbody>

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

                        • <bdo id='UJGBQ'></bdo><ul id='UJGBQ'></ul>

                          1. <legend id='UJGBQ'><style id='UJGBQ'><dir id='UJGBQ'><q id='UJGBQ'></q></dir></style></legend><tfoot id='UJGBQ'></tfoot>