Windows Forms Focus

Z

zobalee

I have a multi-form application that uses a treeview for navigation, which
checks the NodeMouseClick event and simply issues these commands:

theNewForm.Show() : Me.Hide()

....depending on the node the user clicks, of course.

My problem is that when the form is shown it doesn't have focus. Which
really means that the application doesn't have focus. I've tried to
explicitly code it to have focus, and even tried to code focus to one of the
form's controls, all to no avail.

It's weird, because when I issue the exact commands via "Next" and "Back"
buttons on the calling form, it works fine, i.e., the
application/form/control retains focus. My client understandably wants it to
work with both types of controls, so I need to fix this. Anyone have any
ideas why it works for one type of control (button) but not the other
(treeview)? Has anyone run into this problem?

Appreciatively,

Lee...
 
J

Jared

debug form focus and lostfocus event with a trace.writeline and also look at
th windows.form.forms.activeform property to see which form is currently
active.

I would say that code is being fired after you call the line "newform.show"
 
Z

zobalee

Are you opposed to calling ShowDialog() instead? <<

Yeah, that's not an option, I'm afraid. Good suggestion, though.
 
Z

zobalee

Yeah, it seems that's the only thing that makes sense. I thought it was
perhaps a bug in the treeview control and someone would simply confirm it to
me. At the moment I can't see any code that should be causing it, but if
noone else has had a similar experience, I *must have *something firing
somewhere.

I'll try the trace and see what jumps out of the bushes at me.

Thanks for pointing out the duh to me. ;-)

Lee...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top