views:

103

answers:

1

I have a form with a Tab Control that has 18 pages. When I click on a tab it opens the page and select a textbox on that page (txtTextbox1.Select()). This works for the first 8 pages but not for the remaining 10 pages. Although on these pages I can mouse click on the textbox, enter info, save then click my Add button that clears the textboxes and has the code (txtTextbox1.Select()). The textbox is selected just fine.

The code for all my pages is the same except for the tab name and the control names. The tab key will move the selection to the next textbox in order on all pages and the Enter key is coded to do the same. The first 8 pages have a total of 256 labels, buttons, list boxes, textboxes and checkboxes on them.

I’m looking for anyone that may be able to explain why this is happening and that might have a work around or solution for it.

A: 

I'm curious about:

The code for all my pages is the same except for the tab name and the control names.

I'd guess that you created the first one from scratch and did a lot of copy/paste/edit to create each subsequent page. Am I right?

The first thing I'd check would be to see if more than one page is calling Select() on the same TextBox. That would mean that one of them is trying to select a TextBox that's on some other page, not the page being shown. This could happen, for example, if you missed an edit after pasting code from a previous page. (You could try checking by doing a find in files for ".Select" in your whole project and looking for duplicates in the results if the only place you call Select is when a page shows.)

If that's not it, can you move one of the non-selecting pages up to the position of one of the pages that does select? For instance, move page 18 to between page 1 and 2. Does it select its textbox correctly? If it does, then there's something about the position. If it does not, then it's something about the page.

JeffH