Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview won't release focus

Status
Not open for further replies.

DeadIslets

Programmer
Apr 3, 2002
45
US
I have a treeview control that won't programatically pass the focus to a textbox. After the user drills down to the appropriate level in the treeview (I do an edit here to ensure they're at the right level) I enable a groupbox which contains 2 textboxes. I then change to focus to the textbox but it won't take... the focus remains in the treeview. I've tried to change the focus two ways:

txtPolicyNm.Focus
txtPolicyNm.Select

As I indicated neither one of these works, but rather leaves the focus back at the treeview.

Any and all suggestions are GREATLY appreciated!

Keith
 
Try putting the code to set the focus to the textbox in the groupbox's EnabledChanged event handler.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Thanks for the reply, jebenson. Interestingly enough, when I enable the groupbox it does not fire the enabledchanged event. Regardless, as a test, I created a separate textbox disabled, then programatically enabled and passed focus. Unfortunately it did not take either.

I think the problem lies with the treeview releasing focus rather than the textbox receiving it.

Thanks again... any other suggestions?

Keith
 
A little more information on this--I captured the result of the focus operation and it was successful. So this means that something is drawing the focus back to the treeview after the focus was set to the textbox ... (don't ya just love it when you can't see what's going on?!)

BTW, the groupbox.enable as well as the texbox.focus are both done in the treeview.afterselect event.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top