-3

I have shown a new form in button click on parent form like below,

enter image description here

Here the background parent form gets disabled when a new child form is activated.

Is there any available options to show the child form without disabling the parent form?

Regards,

Amal
  • 576
  • 1
  • 6
  • 26
  • 1
    How do you open the new form? – Ofir Winegarten Apr 20 '17 at 12:46
  • 3
    Use `Form.Show()` instead of `Form.ShowDialog()`? – Matthew Watson Apr 20 '17 at 12:47
  • childForm.Visible or ChildForm.Show or childForm.ShowDialog – Amal Apr 20 '17 at 12:48
  • @MatthewWatson - Form.Show also results the same. I dont want the parentform to get deactivated. I.e the parent form looks like kind of disabled and activated again once the child form is closed. – Amal Apr 20 '17 at 12:49
  • When the child is shown give the focus to the parent. – dcg Apr 20 '17 at 12:50
  • @Amal You mean it loses focus? That's how **Windows** works. – ProgrammingLlama Apr 20 '17 at 13:05
  • @Amal, in the image you've provided the window is not disabled. It's just not focused. Click on it and it will get the focus again (assuming you used `Form.Show`). You can't have two focused windows, can you ? – Ofir Winegarten Apr 20 '17 at 13:09
  • 1
    The best you can probably do is [showing the new window without stealing focus](http://stackoverflow.com/questions/156046/show-a-form-without-stealing-focus), but then the new Window won't be focused. That's how Windows (and Linux, Mac, etc.) works. – ProgrammingLlama Apr 20 '17 at 13:11
  • @john - i have tried the createparams technique proposed to not steal the focus of parent when showing the child, but it is not working. – Amal Apr 20 '17 at 13:30
  • OK, is your question that you want the _parent_ to keep focus, and the _child_ not to have focus? Or do you want them _both_ to have focus (you can't - it's impossible). – ProgrammingLlama Apr 20 '17 at 13:34
  • yes, i want focus in parent and not in child – Amal Apr 20 '17 at 13:51
  • i have set ShowWithoutActivation= true and TopMost= false for child form. and the focus is not disabled for parent perfectly. But when i maximize the parent form and show the child form, child form is not showing. – Amal Apr 20 '17 at 13:52

3 Answers3

4

The Show function shows the form in a non modal form. This means that you can click on the parent form.

ShowDialog shows the form modally, meaning you cannot go to the parent form

Application.Run() runs the main parent form, and makes that form the main form. Application.Run() is usually found in main.

Zsmaster
  • 1,549
  • 4
  • 19
  • 28
3

If it is fully disabled (no interaction possible), you are using .ShowDialog() on the child form instead of .Show(). If you use .Show() you will be able to use both forms

Example:

ChildForm childForm = new ChildForm();
childForm.Show();
EpicKip
  • 4,015
  • 1
  • 20
  • 37
-1

after you open the new form and call this.Activate(); it will refocus on the parent window, but this will cause it to loose focus for a fraction of a second

Ben
  • 166
  • 2
  • 19
  • Thanks for your solution. If we can prevent the focus losing of parent, it will be better. – Amal Apr 20 '17 at 12:55