Focus Lost on Form Change

J

Juan

Hello:

I Created some forms in my application, but Have the problem that when I
return from a form, the focus doesn't pass to the parent form , the focus
get lost and I had to click on the parent form to force it to return.

If I click in the "ok" button of the parent form, the event get enqueued,
but doesn't occur, until I click on the form itself.
I tried with "this.Focus()" (on parent form), but it doesn't work, the
focused property of the parent form is well set to TRUE before this point,
but it hasn't the focus.

sample code:

form test = new form();
test.ShowDialog();

test.Dispose(); // here the focus should be in the parent form

test = null;

Application.DoEvents(); //i tried with this, but dont works

this.Focus(); //parent form


How can I solve this problem?

I want the focus to return automatically to the parent form.
Is this a bug?

Thanks a lot.


Juan
NTSMobile
 
M

marcmc

Not sure whether a bug or not have you tried
frmForm1.BringToFront()
txtText1.Focus()
 
J

Juan

Thanks, but this doesn't work.
I've been trying some things and the problem is the event model on .NET
Compact Framework.
I changed the event in where I load the new form, the event was
SelectedIndicesChanged of a listview, I changed it and put ItemActivated and
the problem was solved.
 

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

Top