如何获得后,每个按键preSS在一个WinForms文本框的当前文本? [英] How to get the current text after each key press in a Winforms TextBox?

查看:132
本文介绍了如何获得后,每个按键preSS在一个WinForms文本框的当前文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以过滤项的ListView 为用户键入文本框和我的列表使用的KeyDown 键preSS 事件,但是当我读 textbox.Text ,它总是返回前的最后一个键preSS的文本。有没有一种方法总是得到任何显示在文本框无pressing进入?

I am trying to filter a list of items in a ListView as the user types into a TextBox and I use KeyDown, and KeyPress events but when I read the textbox.Text, it always returns the text before the last key press. Is there a way to always get whatever is shown in the TextBox without pressing enter?

推荐答案

使用的 TextBox.TextChanged 事件(从控制继承)。

时发生的Text属性值的变化。

Occurs when the Text property value changes.

我的建议是尽量不要与关键事件破解这个(下/ preSS /上) - 还有其他的方法来改变文本框的文字,如通过从右键单击上下文粘贴文本菜单。这不涉及pressing的关键。

My advice is to try not to hack this with the key events (down / press / up) - there are other ways to change a text-box's text, such as by pasting text from the right-click context menu. This doesn't involve pressing a key.

这篇关于如何获得后,每个按键preSS在一个WinForms文本框的当前文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆