problem with textbox.focus()


        private void button1_click(object sender, eventargs e)
        {
            if (textbox1.focus())
            {
                textbox1.text = textbox1.text + 1;
            }
            else if (textbox2.focus())
            {
                textbox2.text = textbox2.text + 1;
            }
        }
how come everytime click button1, it's add "1" textbox1 though focus on textbox2? 

hi

this because focus() set focus textbox. instead use following

 private void button1_click(object sender, eventargs e)
        {
            if (textbox1.focused==true)
            {
                textbox1.text = textbox1.text + 1;
            }
            else if (textbox2.focused == true)
            {
                textbox2.text = textbox2.text + 1;
            }
        }


sampada



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'