What I want to do is:
click on button1 in form1---> loads form2 ---->set focus to a textbox1 in form2 and show IBeam Cursor there.

I tried textbox1.Focus() in Load, but it only do it for the first time I click button1, when I click button1 again, it loads form2, if I type something now, it won't show in textbox1, I don't know where it goes, no cursor in textbox1 either.

Then I tried assigning textbox1 the lowest 'TabIndex' on form2, still won't work. Why? What else can I do?

Recommended Answers

All 3 Replies

check to make sure you do not have two or three items marked with the 0 tabindex.

Wayne, I just double checked, form2 is actually very simple, just one textbox, 1 label and 2 buttons, I did set tabIndex of the textbox to 0 and it is the only one in this form whose tabIndex is 0. What happened? Is there any workaround to achieve the same result?

I know how to do it now, instead of set focus Form_Load event, set it in Form_Activated event, because no Controls are visible at Form_Load and hence focus cannot be set. Still don't know why the tabindex method won't work though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.