You must Sign In to post a response.
  • Category: Windows

    Textbox focus

    i have 10 textboxes.my need is which textbix is now foucused.
    i need if conditions for which textbox foucusing true.


    im tried this not working:

    if (textBox1.Focus()==true)
    {

    MessageBox.Show("txtbox1 focusing");

    }

    pls give correct code:
  • #507749
    Where you want to check this condition?

    Once Page loads then only focus will takes place to respective control

    any way here is a piece of code try this

    if (textBox1.Focused)
    MessageBox.Show("Textbox1 Focused");

    Thanks!
    Regards,
    Narendra

  • #507753
    How you are checking this? Textbox has no event called focus. So on focus of the textbox your code will not fire. you may use javascript.

    Regards,
    Asheej T K

  • #507756
    its windows form textboxes only i need button click:
    its not working ya

  • #507760
    Yes Srinivasan, it wont work coz once you click button focus will come on to that button, not on to the textboxes.

    you can check by placing this code in button click event

    if (button1.Focused)
    MessageBox.Show("Button1 Focused");

    Thanks!
    Regards,
    Narendra


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.