完成输入后如何从文本框中保存数据 [英] How to save data from textbox after finish typing

查看:284
本文介绍了完成输入后如何从文本框中保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有问题我在文本更改事件中写更新语句。但是当任何字符更改时重复更改

示例

用户名文本框并且名称为ahmed和我需要换到ahmedsalah

它保存在数据库中

ahmeds

ahmedsa

ahmedsal

ahmedsala

ahmedsalah

它保存5次

如何在完成打字后允许文本框保存

我有sql 2005

visual studio 2008

如果可能帮助我

Hi guys i have problem i write update statement in text changed event.but repeated changed when any character changed
example
user name text box and has name ahmed and i need to change to ahmedsalah
it save in database as
ahmeds
ahmedsa
ahmedsal
ahmedsala
ahmedsalah
it save 5 times
how please to allow text box to save after finish typing
I have sql 2005
visual studio 2008
if possible help me

推荐答案

最简单的方法如果要将代码从TextChanged事件移动到离开 [ ^ ]事件 - 当用户已完成输入时。



备选方案ly,只有在登录成功时才存储它 - 这样amhedsalah也不会被存储,因为在登录DB中找不到用户名。
The easiest way if to move the code from your TextChanged event to the Leave[^] event - as the user has finished input by then.

Alternatively, store it only when the login is successful - that way "amhedsalah" doesn't get stored either because the username isn't found in the login DB.


它没有任何意义所有,只是可怕的UI想法。您不应该对文本更改事件执行任何主动操作,因为您会使用户生活成为一场噩梦,并使互联网流量膨胀等等。只有用户知道他/她何时完成输入,因此只有用户才能触发输入字符串的处理,只需点击一下或键盘命中(例如回车)。



当然,有一些排除,例如在字典中搜索。但这是一个非常具体的案例;此外,它只能应用于本地字典,而不能在线。



-SA
It makes no sense at all, just the dreadful UI idea. You should not do any active action on text changing event, as you make the user life a nightmare, and bloat Internet traffic and so on. Only the user knows when she/he finishes the entry, so only the user can trigger handling of the input string, with some click or keyboard hit (such as Enter).

Of course, there are some exclusions, such as the search in a dictionary. But this is a very specific case; moreover, it can only be applied to a local dictionary, not online.

—SA


这篇关于完成输入后如何从文本框中保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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