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

    1. <tfoot id='G0OZa'></tfoot>

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

        .NET --- 文本框控件 - 等到用户完成输入

        .NET --- Textbox control - wait till user is done typing(.NET --- 文本框控件 - 等到用户完成输入)

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

                  <tfoot id='TNq1r'></tfoot>
                    <tbody id='TNq1r'></tbody>
                  <legend id='TNq1r'><style id='TNq1r'><dir id='TNq1r'><q id='TNq1r'></q></dir></style></legend>
                1. <small id='TNq1r'></small><noframes id='TNq1r'>

                  本文介绍了.NET --- 文本框控件 - 等到用户完成输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  大家好,

                  是否有内置方法可以知道用户何时在文本框中完成输入?(在点击选项卡或移动鼠标之前)我有一个发生在 textchanged 事件上的数据库查询,并且一切正常.但是,我注意到当然有一点延迟,因为如果用户快速输入文本框,程序正忙于对每个字符进行查询.所以我希望的是一种查看用户是否完成输入的方法.因此,如果他们键入a"并停止,则会触发一个事件.但是,如果他们键入一直",则事件会在 y 键后触发.

                  Is there a built in way to know when a user is done typing into a textbox? (Before hitting tab, Or moving the mouse) I have a database query that occurs on the textchanged event and everything works perfectly. However, I noticed that there is a bit of lag of course because if a user is quickly typing into the textbox the program is busy doing a query for each character. So what I was hoping for was a way to see if the user has finished typing. So if they type "a" and stop then an event fires. However, if they type "all the way" the event fires after the y keyup.

                  我有一些想法在我脑海中浮现,但我确信它们不是最有效的.就像测量自上次 textchange 事件以来的时间,如果大于某个值,那么它将继续运行我的其余程序.

                  I have some ideas floating around my head but I'm sure they aren't the most efficient. Like measuring the time since the last textchange event and if it was > than a certain value then it would proceed to run the rest of my procedures.

                  让我知道你的想法.

                  语言:VB.NET框架:.Net 2.0

                  Language: VB.NET Framework: .Net 2.0

                  --编辑澄清完成打字"

                  --Edited to clarify "done typing"

                  推荐答案

                  一种方法:

                  1. 创建一个 TimerInterval 为 X 毫秒

                  间隔应该是300ms左右;超过正常的击键时间,以及完成和更新发生之间的合理等待时间

                  The interval should be about 300ms; more than a normal time between keystrokes, and also reasonable time to wait between finishing and the update occurring

                  在输入的 TextChanged 事件中,Stop() 然后 Start() Timer

                  In the input's TextChanged event, Stop() and then Start() the Timer

                  如果 Timer 已经在运行,这将重新启动它,因此如果用户继续以正常速度输入,每次更改都会重新启动计时器.

                  This will restart the Timer if it is already running, so if the user keeps typing at a normal rate, each change will restart the timer.

                  在定时器的Tick事件中,Stop()Timer并做长事务

                  In the timer's Tick event, Stop() the Timer and do the long transaction

                  可选:处理 LeaveKeyDown 事件,以便离开控件或按 EnterStop() Timer 并进行长事务.

                  Optional: Handle the Leave and KeyDown events so that leaving the control or pressing Enter will Stop() the Timer and do the long transaction.

                  如果文本已更改,并且用户在 X 毫秒内没有进行任何更改,这将导致更新.

                  This will cause an update if the text has changed, and the user hasn't made any changes in X milliseconds.

                  测量自上次更新以来的时间"的一个问题;您正在考虑的方法是,如果快速进行最后一次更改,则不会发生更新,并且不会有任何后续更改触发另一次检查.

                  One problem with the "Measure the time since the last update" approach you're considering is that if the last change is made quickly, the update won't happen, and there won't be any subsequent changes to trigger another check.

                  注意:TextBoxes和Timers之间必须是一对一的配对;如果您打算使用多个输入来执行此操作,我会考虑构建一个包装此功能的 UserControl.

                  Note: There must be a one to one pairing between TextBoxes and Timers; if you're planning on doing this with more than one input, I'd consider building a UserControl that wraps this functionality.

                  这篇关于.NET --- 文本框控件 - 等到用户完成输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 删除整个单词)
                  Multi-color TextBox C#(多色文本框 C#)
                  How can i set the caret position to a specific index in passwordbox in WPF(如何将插入符号位置设置为 WPF 密码框中的特定索引)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                  Unicode characters not showing in System.Windows.Forms.TextBox(System.Windows.Forms.TextBox 中未显示 Unicode 字符)
                    <bdo id='x4pil'></bdo><ul id='x4pil'></ul>

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

                      <tbody id='x4pil'></tbody>
                  • <legend id='x4pil'><style id='x4pil'><dir id='x4pil'><q id='x4pil'></q></dir></style></legend>

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