Cant unhide all child forms? vb.net - vb.net

I have the flowing problem. I have a vb.net parent form with MDI children that contain sensitive information. I have made a pause button which should hide all child forms from sight, this is no problem, calling them back is. i have for testing purposes created a button which should do the reverse however all my child forms stay hidden can somebody assist?
Code to hide all child forms is as follows:
For Each frmApproval As Form In Me.MdiChildren
frmApproval.Visible = False
Next
System_Paused.MdiParent = Me
System_Paused.Show()
Now the form nammed System_Paused has a button on it which when clicked should revert the hidden child forms but its not working?
For Each frmApproval As Form In Me.MdiChildren
frmApproval.Visible= true
Next
Me.Close()

You're iterating over the wrong MdiChildren collection.
You hide the children of your main form, but then you try to set the visibility of the children of the System_Paused form.
You could solve this issue by using something like this:
For Each frmApproval As Form In Me.MdiParent.MdiChildren
frmApproval.Visible = true
Next
since you already set your main form as MdiParent of the System_Paused form.

Related

Requery a subform from another form from a navigation Form

I have a problem with refreshing a subform from another form in navigation form
Here it is:
I have a form called MainForm in it is one sub form called MainSubForm..
From the link in a row in MainSubForm if you click it will open the third form like popup called ClientForm that will show the details of client on row selected on MainSubForm. Till here is everything ok, but in popup ClientForm form I have to edit some data, clos ClientForm and refresh the MainSubForm.
My code in ClientForm is like this:
Forms.MainForm.MainSubForm.Form.Requery
DoCmd.Close
When I open the MainForm normally it is work perfect, but when I open the MainForm form from my Navigation Form it is not working.
Info: I have navigation form that I put all my forms that i needet in there ( MainSubForm not in navigation form )
Thanx in advance,
If you retain the default names assigned by Access (Navigation Form and NavigationSubform), the following should work to requery form/subform placed on Navigation Form (it does for me).
Forms![Navigation Form].NavigationSubform.Requery

vb.net mdi parent hides when another form opens

I have a program written in vb.net. It has a mdi parent form as the main form and several child forms. I also have dozens of forms that are not child forms and when I use showdialog() the mainform(MDI parent) hides behind other open applications until the the new form(not child form) finishes opening. I tried showdialog(me) and it doesn't work. I can't use just form.show(me). I searched for hours and can't find a fix. Any help would be greatly appreciated.
form2.TopMost = True
form2.WindowState = FormWindowState.Normal
form2.ShowDialog(Me)
this code is called from toolstripmenu from the mainform

Make an MDI child form no longer a child

Using VB.Net:
Is there a way to make a child form that is inside an MDI parent form no longer a child form? For example, I have an entryForm.vb inside of mainForm.vb. On double click (or other event) I want entryForm.vb to be fully sizable and outside of the mainForm.vb without losing text.
I have tried changing the MDI settings of entryForm.vb but that does not seem to work.
Set the property MDIParent of the form instance to Nothing

how to know my application lost focus in VB.NET

I am using VB.NET to build my application. And in my application has a lot of Forms. It doesn't use MDI Parent Form, but I use another simple Window Form (I named it frmMain) that I suppose it is my MDI Parent Form. When frmMain load, windowState = Maximized. And when I open a Form (example: I named it frmCustomer) that I suppose it is my child Form, and I set its properties (frmCustomer.TopMost=True) when it load, so it always on the top. But When I change to open another application such as Ms. Word or Mozilla Firefox... the frmCustomer is still on the top. My question is that; how can I know my frmMain lost focus?
If you want the form to stay in front of the main form, but not other applications, the simpler solution would be to set the main form as the child form's owner. For instance:
childForm.Show(parentForm)
or
childForm.Owner = parentForm

VB.NET Difference between Focus() and BringToFront()

I'm developing an application in WinForms and I have 2 MDI children and I'd like to know the difference between Form.Focus and Form.BringToFront
I would like to know which one to use when clicking on a respective form's titlebar in order to have it pop up while I'm drag/dropping the form
If you are setting the child form mdiParent property after you are calling Form.Show then it messes up the focus of all the child forms so for me, drag/drop of MDI children inside an MDI parent won't focus the form upon Drag start, but only after MouseUp
Focus() sets focus to U element.
BringToFront() brings your element on top of other elements (which overlap your element).
So if you use BringToFront() on your form, it will be brought to front over over windows in your MDI environment. But it doesn't mean that your form will gain focus.
If you use Focus(), your form will gain focus: for example you will be able to interact with the form via keyboard. But it does not mean that form will be brought to front over other forms.
So maybe you should use both methods.
When I open MDI Child Forms, I create the following function within the MDI Parent:
Public Sub ShowMDIChild(f As Form)
f.MdiParent = Me
f.Show()
End Sub
The "f" argument is the new form I wish to open:
MyMDIPParent.ShowMDIChild(New Hospitals)