在Command Button的OnClick事件之后触发Textbox LostFocus事件

编程入门 行业动态 更新时间:2024-10-26 02:36:05
本文介绍了在Command Button的OnClick事件之后触发Textbox LostFocus事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

WINDOWS FORMS 我有一个包含文本框的表单,允许用户输入字符串。 在LostFocus事件中, textbox将字符串格式化为首选的 格式。 但是,如果用户按下保存字样。按钮,而文本框有焦点,LostFocus代码没有在正确的时间运行,所以 保存按钮函数正在处理格式错误的字符串和 整个caboodle会啪嗒一声。 我喜欢LostFocus事件,因为我已经超过了14在表单上的各个选项卡上的这些 文本框,它们可能包含不同的 字符串,但必须以正确的格式进行格式化。这是处理这个的 函数: Private Sub txtTimeStartAndEndArbitrated(ByVal sender As Object, ByVal e As System。 EventArgs)处理txtMonStartArbitrated.LostFocus, txtMonEndArbitrated.LostFocus,_ txtTueStartArbitrated.LostFocus,txtTueEndArbitrated.LostFocus,_ txtWedStartArbitrated.LostFocus,txtWedEndArbitrated .LostFocus,_ txtThurStartArbitrated.LostFocus,txtThurEndArbitrated.LostFocus, _ txtFriStartArbitrated.LostFocus,txtFriEndArbitrated.LostFocus,_ txtSatStartArbitrated.LostFocus,txtSatEndArbitrated.LostFocus,_ txtSunStartArbitrated.LostFocus,txtSunEndArbitrated.LostFocus Dim txtTextBox As TextBox = CType(sender,TextBox ) txtTextBox.Text = FormatArbTime(txtTextBox.Text) 结束子 任意想法? 爱德华

解决方案

Edward, 为什么不在保存按钮上将enabled属性设置为false,并在 上设置lostfocus事件,启用保存按钮,以及每个 文本框的getfocus,将保存按钮上的启用设置为false,直到填充文本框 ? - Michael Bragg,总裁 eSolTec,Inc。 a 501(C)(3)组织 MS授权MAR 寻找用于发育障碍的二手笔记本电脑。 " te ******** @ hotmail"写道:

WINDOWS FORMS 我有一个包含文本框的表单,允许用户输入字符串。 在LostFocus事件中,文本框将字符串格式化为首选的 格式。 但是,如果用户按下保存按钮,而文本框有焦点,LostFocus代码没有在正确的时间运行,所以 保存按钮函数正在处理格式错误的字符串和 整个caboodle会啪嗒一声。 我喜欢LostFocus事件,因为我已经超过了14在表单上的各个选项卡上的这些 文本框,它们可能包含不同的 字符串,但必须以正确的格式进行格式化。这是处理这个的 函数: Private Sub txtTimeStartAndEndArbitrated(ByVal sender As Object, ByVal e As System。 EventArgs)处理txtMonStartArbitrated.LostFocus, txtMonEndArbitrated.LostFocus,_ txtTueStartArbitrated.LostFocus,txtTueEndArbitrated.LostFocus,_ txtWedStartArbitrated.LostFocus,txtWedEndArbitrated .LostFocus,_ txtThurStartArbitrated.LostFocus,txtThurEndArbitrated.LostFocus, _ txtFriStartArbitrated.LostFocus,txtFriEndArbitrated.LostFocus,_ txtSatStartArbitrated.LostFocus,txtSatEndArbitrated.LostFocus,_ txtSunStartArbitrated.LostFocus,txtSunEndArbitrated.LostFocus Dim txtTextBox As TextBox = CType(sender,TextBox ) txtTextBox.Text = FormatArbTime(txtTextBox.Text) 结束子 任意想法? Edward

尝试使用文本框'''验证'"事件......这就是它的用途,应该 工作。 - 丹尼斯在休斯顿 " eSolTec,Inc。501(c)(3)"写道:

Edward, 为什么不在保存按钮上设置启用属性为false lostfocus事件,启用保存按钮,并在每个 文本框的gotfocus上,将保存按钮上的启用设置为false,直到文本框<是否填充了? - Michael Bragg,总裁 eSolTec,Inc。 a 501(C)(3)组织 MS授权MAR 寻找用于发育障碍的二手笔记本电脑。 " ; TE ******** @ hotmail"写道:

WINDOWS FORMS 我有一个包含文本框的表单,允许用户输入字符串。 在LostFocus事件中,文本框将字符串格式化为首选的 格式。 但是,如果用户按下保存按钮,而文本框有焦点,LostFocus代码没有在正确的时间运行,所以 保存按钮函数正在处理格式错误的字符串和 整个caboodle会啪嗒一声。 我喜欢LostFocus事件,因为我已经超过了14在表单上的各个选项卡上的这些 文本框,它们可能包含不同的 字符串,但必须以正确的格式进行格式化。这是处理这个的 函数: Private Sub txtTimeStartAndEndArbitrated(ByVal sender As Object, ByVal e As System。 EventArgs)处理txtMonStartArbitrated.LostFocus, txtMonEndArbitrated.LostFocus,_ txtTueStartArbitrated.LostFocus,txtTueEndArbitrated.LostFocus,_ txtWedStartArbitrated.LostFocus,txtWedEndArbitrated .LostFocus,_ txtThurStartArbitrated.LostFocus,txtThurEndArbitrated.LostFocus, _ txtFriStartArbitrated.LostFocus,txtFriEndArbitrated.LostFocus,_ txtSatStartArbitrated.LostFocus,txtSatEndArbitrated.LostFocus,_ txtSunStartArbitrated.LostFocus,txtSunEndArbitrated.LostFocus Dim txtTextBox As TextBox = CType(sender,TextBox ) txtTextBox.Text = FormatArbTime(txtTextBox.Text) 结束子 任意想法? 爱德华

te ******** @ hotmail 写道: [snip] 谢谢,伙计们,我会给这些镜头。 爱德华

WINDOWS FORMS I''ve a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user presses the "Save" button while the textbox has the focus, the LostFocus code doesn''t run at the right time, so that the "Save" function is dealing with an incorrectly formatted string and the whole caboodle goes splat. I like the LostFocus event, because I''ve got upwards of 14 such textboxes on various tabs on the form, which all may contain different strings but must all be formatted in the correct format. Here is the function that handles this: Private Sub txtTimeStartAndEndArbitrated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMonStartArbitrated.LostFocus, txtMonEndArbitrated.LostFocus, _ txtTueStartArbitrated.LostFocus, txtTueEndArbitrated.LostFocus, _ txtWedStartArbitrated.LostFocus, txtWedEndArbitrated.LostFocus, _ txtThurStartArbitrated.LostFocus, txtThurEndArbitrated.LostFocus, _ txtFriStartArbitrated.LostFocus, txtFriEndArbitrated.LostFocus, _ txtSatStartArbitrated.LostFocus, txtSatEndArbitrated.LostFocus, _ txtSunStartArbitrated.LostFocus, txtSunEndArbitrated.LostFocus Dim txtTextBox As TextBox = CType(sender, TextBox) txtTextBox.Text = FormatArbTime(txtTextBox.Text) End Sub Any thoughts? Edward

解决方案

Edward, Why don''t you set the enabled property to false on the save button and on the lostfocus event, enable the save button, and on the gotfocus of each textbox, set the enabled on the save button to false, until the textbox(es) are populated? -- Michael Bragg, President eSolTec, Inc. a 501(C)(3) organization MS Authorized MAR looking for used laptops for developmentally disabled. "te********@hotmail" wrote:

WINDOWS FORMS I''ve a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user presses the "Save" button while the textbox has the focus, the LostFocus code doesn''t run at the right time, so that the "Save" function is dealing with an incorrectly formatted string and the whole caboodle goes splat. I like the LostFocus event, because I''ve got upwards of 14 such textboxes on various tabs on the form, which all may contain different strings but must all be formatted in the correct format. Here is the function that handles this: Private Sub txtTimeStartAndEndArbitrated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMonStartArbitrated.LostFocus, txtMonEndArbitrated.LostFocus, _ txtTueStartArbitrated.LostFocus, txtTueEndArbitrated.LostFocus, _ txtWedStartArbitrated.LostFocus, txtWedEndArbitrated.LostFocus, _ txtThurStartArbitrated.LostFocus, txtThurEndArbitrated.LostFocus, _ txtFriStartArbitrated.LostFocus, txtFriEndArbitrated.LostFocus, _ txtSatStartArbitrated.LostFocus, txtSatEndArbitrated.LostFocus, _ txtSunStartArbitrated.LostFocus, txtSunEndArbitrated.LostFocus Dim txtTextBox As TextBox = CType(sender, TextBox) txtTextBox.Text = FormatArbTime(txtTextBox.Text) End Sub Any thoughts? Edward

Try using the textbox''s "Validating" event..that''s what it is for and should work. -- Dennis in Houston "eSolTec, Inc. 501(c)(3)" wrote:

Edward, Why don''t you set the enabled property to false on the save button and on the lostfocus event, enable the save button, and on the gotfocus of each textbox, set the enabled on the save button to false, until the textbox(es) are populated? -- Michael Bragg, President eSolTec, Inc. a 501(C)(3) organization MS Authorized MAR looking for used laptops for developmentally disabled. "te********@hotmail" wrote:

WINDOWS FORMS I''ve a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user presses the "Save" button while the textbox has the focus, the LostFocus code doesn''t run at the right time, so that the "Save" function is dealing with an incorrectly formatted string and the whole caboodle goes splat. I like the LostFocus event, because I''ve got upwards of 14 such textboxes on various tabs on the form, which all may contain different strings but must all be formatted in the correct format. Here is the function that handles this: Private Sub txtTimeStartAndEndArbitrated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMonStartArbitrated.LostFocus, txtMonEndArbitrated.LostFocus, _ txtTueStartArbitrated.LostFocus, txtTueEndArbitrated.LostFocus, _ txtWedStartArbitrated.LostFocus, txtWedEndArbitrated.LostFocus, _ txtThurStartArbitrated.LostFocus, txtThurEndArbitrated.LostFocus, _ txtFriStartArbitrated.LostFocus, txtFriEndArbitrated.LostFocus, _ txtSatStartArbitrated.LostFocus, txtSatEndArbitrated.LostFocus, _ txtSunStartArbitrated.LostFocus, txtSunEndArbitrated.LostFocus Dim txtTextBox As TextBox = CType(sender, TextBox) txtTextBox.Text = FormatArbTime(txtTextBox.Text) End Sub Any thoughts? Edward

te********@hotmail wrote: [snip] Thanks, guys, I''ll give these a shot. Edward

更多推荐

在Command Button的OnClick事件之后触发Textbox LostFocus事件

本文发布于:2023-11-11 18:42:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579264.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   Button   Command   OnClick   LostFocus

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!