本文介绍了两个TextBox GotFocus()递归了.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我一直在研究Windows Mobile表单.我有一个带有两个文本框的Windows Mobile应用程序表单.

1.两个文本框值都是强制性的.
2.在编辑模式下,如果将TextBox1聚焦并使其为空,然后用户导航到TextBox2,则需要显示一条消息"TextBox1中的值是强制性的",并且控件需要将注意力集中在TextBox1上.3.同样,如果填充了TextBox1并将焦点移至TextBox2,并且如果用户将焦点移至窗体上除TextBox1和TextBox2之外的其他任何位置,则应将TextBox2对准焦点,并显示一条消息,指出"TextBox1中的值是必需的" >
但是,当使用TextBox1_GotFocus()和TextBox2_GotFocus()实现此功能时,由于调用变为递归并引发了stackoverflow异常,我遇到了异常.

我怎么能克服这个.感谢您的帮助.

Hi,

I have been working on Windows Mobile Forms. I have a windows mobile application form with two textbox.

1. Both textbox value is mandatory.
2. At edit mode, if TextBox1 is focused and made empty and then user navigate to TextBox2 then there a message need to be shown "Value in TextBox1 is mandatory" and control needs to focus back on TextBox1.
3. Similarly if TextBox1 is filled and focus is shifted to TextBox2 and if user places focus to any other place on form except TextBox1 and TextBox2 then TextBox2 should be focused and a message to be shown as "Value in TextBox1 is mandatory"

But while implemeting this with TextBox1_GotFocus() and TextBox2_GotFocus() I got exception as the call becomes recursive and a stackoverflow exception is thrown.

How could I get over this. Any help is appreciated.

推荐答案



这篇关于两个TextBox GotFocus()递归了.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:16