Blocking interaction between child and main parent form vb - vb.net

At the moment, I have a project I'm working on with a menu that opens a new window. Annoyingly, when the new window is opened, it just does everything the main parent window does that the new window is opened up from. I want to be able to have the new window be able to do it's own thing and not just share what ever the parent is doing. Is there anything I can do at a button's click to give this form some kind of attribute that disallows this?

You can use seperate form. the working of each form will depend on what you specified in that particular form.. You can use the MDI form. and call all child forms under the mdi form. the child form will open in seperate window under MDI form.
you can simply call the child form as
Private Sub MembersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MembersToolStripMenuItem.Click
Dim xfrm As New childForm
xfrm.MdiParent = Me
xfrm.Show()
End Sub

Related

Prevent ListView from bringing old form to front

I have a form (we'll call it Form A) that contains a ListView control. When I select an item in the ListView, the event handler creates and shows a Form B.
I want Form B to appear in front of Form A. Both forms are maximized when shown. The problem is, the ListView in Form A is making Form A take the focus back right after Form B is shown. The screen flickers temporarily, so Form B is initially in front. I know it's the ListView doing it because if I open Form B from another control, it works as intended.
I'm displaying Form B with Show(). Changing it to ShowDialog() fixes the problem, but I don't want it to be modal.
This is happening during the handler for the ListView1.ItemSelectionChanged event, and changing to ListView1.SelectedIndexChanged doesn't help.
Some code, if it makes it any clearer:
Private Sub ListView1_ItemSelectionChanged(sender As Object, e As ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
If e.IsSelected Then
Dim my_form As New MyForm
my_form.Show()
End If
End Sub
Set the ListViews Activation Property to "OneClick", then handle the ItemActivate Event and display your Form from there.

How create a sub-forms in vb.net

I will like to create 2 windows forms using vb.net
The 1st window forms is main and the second window forms is for sub-window forms and they appear at the same time when run the program
When i close the sub-windows forms it will not close my program, if i close the main window forms it will close my program.
How can i do that ?
When you open the second form, set the owner to the parent form and when you close the parent, it will force the child to close as well. I believe (at least it seems it did this at one time in VB history) that if you hide the parent, it will hide the child too.
If you are using SHOW to display you 'Sub-Form', pass the parent form to it like this:
Form2.show(Form1)
If you are trying to close the owner form when the child form is closed and (if the owner is the starting form of the entire program) end the program, then you will first want to do what Steve has answered to assign form1 as the owner of form2.
Then, to make the child form close the parent, use the following code in form2's FormClosed event:
Private Sub Form2_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Me.Owner.Dispose()
End Sub

MDI open tab on item drag

so I'm having some trouble with opening the tab to where I want to drag some data.
I have 2 child MDI forms, with both a listview.
I would like to drag a listviewitem from mdichild 1 to mdichild 2.
The problem is that I am not able to find the correct event that makes it possible to SHOW the second form when I drag my data to the corresponding MDI tab.
Right now the only thing I get when I drag data to a MDI tab is the standard black circle with a stripe through it.
Any ideas on how to open the tab?
All help is appreciated
It is difficult to tell without code where you problem is, but could it be as simple as this?
Private Sub MDIChildForm_DragEnter(sender As System.Object, e As _
System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
Me.Activate()
Me.WindowState = FormWindowState.Normal
End Sub
This will un-minimize and activate the child form when you drag over it. This is assuming your "Tab" is a minimized MDI child form...

Form maximize on another form

I have an MDI application which contains many child forms
My problem is, on clicking a particular menu, I am opening a form with maximize window in the MDI form. This works fine.
Now if I open another form above the first one, and if i want the second form to be of normal size, i am unable to do it.
Second form also opens with maximized window similar to first one. I want the second form to be of normal small size.
I want to show second form normally and first form maximized.
How can i do that?
Private Sub TESTToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TESTToolStripMenuItem.Click
Dim f As New newCalendar2("UGHARANI")
f.Show()
f.MdiParent = Me
f.WindowState = FormWindowState.Maximized
End Sub
Okay, I think I understand what you're trying to accomplish: you want the first (data) form to be a kind of background to your MDI application and have the other forms display on top of it, right?
Well one way to do it might be to remove borders from the background form –FormBorderStyle = None– and fill-dock it in the MDI parent form. Although it would end up coming to the fore and hiding all your other forms if a user clicked anywhere on it. But if it doesn't require any user interaction you could always use its Activate event to send it back to the background, using Me.SendToBack().

vb.net: setting focus on nested custom controls

I have a nested custom control that I need to set focus on. I have it all internally wired up to automatically set the focus when the form loads, but when it comes up on screen, the designated accept button for the parent form is in focus instead. Even when is disassociate the accept button it still does not set correctly. How can I ensure my desired control gets focus.
I think what you're asking is that you would like to make a textbox (or button, etc) on a user control have focus when the form loads. Try setting the ActiveControl of the user control to the textbox (or which ever control) and then calling focus on it. For example:
Private Sub myUserControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ActiveControl = myTextbox
myTextbox.Focus()
End Sub
Set the tab order. If your custom control is on the same level as buttons (has the same parent), make sure your control and any containter it is in has tab index 0.