0

I am working in Windows Form framework of c# , i have developed a form consisting of two textboxes (name and address). Problem is when i start my application focus is on address rather then name, how can i change this settings? Thank you in advance.

3
  • Get the Load-Event and in this event call tbName.Focus() or you can change the tab-order in the form. Commented Aug 29, 2012 at 7:22
  • i have tried tab order, name box has 1 and address is 2 ... Still not working. Commented Aug 29, 2012 at 7:23
  • Do you want the focus or the access for user input? Commented Aug 29, 2012 at 7:26

5 Answers 5

4

Hope this ll help you. Select will change for user input

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        textBoxName.Select();
        textBoxName.Focus();

    }
}
Sign up to request clarification or add additional context in comments.

Comments

1

In Form_Load event call:

yourTextBox.Focus();

You may look at Control.Focus() on msdn

You may also look at this article to Set the Tab order if you don't want to use Focus()

1 Comment

All Are best answers, but this one is the best in all. :) Thank You Very Much.
1

Just set the Tab Index property of the textbox as 0. Otherwise you can set call the focus method on load event

Comments

1

set focus on the text box like this

txtbxname.Focus();

Comments

0

I personally use the ActiveControl property. Never failed me as of today.

ActiveControl = Address;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.