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

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user