Cannot tab to the the next text box

Chrisetiquette

New member
Joined
Jun 8, 2016
Messages
2
Programming Experience
3-5
Hey all! I'm trying to do the below in C# in Visual Studio WPF

I'm trying to get the functionality to tab to the next text box once the user has input their data for the previous text box. For example, once they filled in a company name I'd like to be able to hit the "TAB" button and set the focus on the next text box "Job Name". Is this done in the code or the form properties?

Here is some of my code. I'm unsure how to nest a KeyEventsArgs within these, which is how I've seen others set the focus to the next text boxes using the KeyPress function.
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            CompanyName = textBox1.Text;
            textBox1.AcceptsTab = true;
            
          
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            JobName = textBox2.Text;
            textBox2.AcceptsTab = true;
        }

Any help would be greatly appreciated, thanks.
 

Attachments

  • FormPreview.jpg
    FormPreview.jpg
    16.7 KB · Views: 64
Last edited by a moderator:
You don't have to do anything at all. What you're describing is the default behaviour. The Tab order is determined by the order of the elements in the XAML code. If the user presses the Tab key while in one of those TextBoxes, focus will shift to the other.
 
Yes, but it is not doing so. The focus remains on the first box.... Something that may be worth noting is that I am opening a windows form by pressing a button on teh WPF form. It is on the windows form that i have the text boxes in which I cannot tab through.
 
Last edited:

Latest posts

Back
Top Bottom