Click here to Skip to main content
15,068,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi please anybody knows reason for this just update here,

I've a TextBox control with PreviewLostKeyboardFocus.

Inside PreviewLostKeyboardFocus I'm calling a method to throw a custom MessageBox(System.Windows.Forms,MessageBox.Show())

So, when the message get called the PreviewLostKeyboardFocus calls itself again and again. I've put example code here,

C#
private void txt1_PreviewLostKeyboardFocus_1(object sender, KeyboardFocusChangedEventArgs e)
        {
            try
            {
                txt1_call();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message);
            }
        }

 private void txt1_call()
        {
            try
            {
                System.Windows.Forms.MessageBox.Show("1");
                System.Windows.Forms.MessageBox.Show("2");
            }
            catch (Exception)
            {
                throw;
            }
        }


This looping not happening when I run the same code in windows7. But recently I've upgraded my machine to Windows8. In windows8 this problem arises. I'm using VS2012. I'm using framework 4.0. Anyway if I use System.Windows.MessageBox.Show() function its not looping. Anyway why for the first method worked in windows7 but not windows8? Suggestions welcome.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900