docking and changing width replaces docked forms - vb.net

I'm currently working on a Windows Forms Application that is essentially a bunch of forms laid on top of each other. Right now, I have this...
MainForm - MDI Parent
ChildForm - Dock set to 'Fill' in MainForm
Sidebar1 - Dock set to 'Left' in MainForm
Sidebar2 - Dock set to 'Right' in MainForm - able to be resized
ChildChildform - Dock set to 'fill' in MainForm, overtop of Childform
So here's my issue - since Sidebar2 is able to be resized widthwise, I figured it would work fine to throw a button on that does the resize for me - push a button, it slides in, push a button, it slides out - kind of like a slide out on screen keyboard. However, when I slide this out while ChildChildForm is up, ChildChildform dissappears and it goes back to displaying Childform.
My best guess is that since ChildForm and Sidebar1 are both set to MDIParent = MainForm, it's displaying on ChildForm First, since ChildChildForm is set to MDIParent = Mainform, but it's the second one...
Anyone have any tips on how to roll the sidebar in to the topmost form if that topmost form is an MDIChild?

Related

Invalidating panel scrollbars

I have set a Panel to AutoScroll = True.
I host a button in this panel.
When I set the button to a new location outside the panel's visible area...
.Location = New Point(2000, 0)
... this doesn't make the scrollbars appear.
How could I force the panel to invalidate / check again if the scrollbars should be shown?
I got it:
I need to set the button's parent to something else, then add it to the panel again which raises the ControlAdded event.

VB NET What is the good way to find a position of an object inside a scrollable panel?

I have an object inside a scrollable panel, and I want to get the position of the object. Everything is okay until I have create many object inside the panel until the panel needed to be scrolled. Then I notice that the X Position of the object changed after scrolling the panel. Take a look at example image below
X Position inside a scrollable panel
I'm using Position.X to get a X Position of the object, but as you can see in the picture above. It does me no good.
Is there a way to get the actual position even if the panel is scrolled ?
UPDATE:
I have One Panel that have Auto Scroll as True , and on Button inside a Panel, let's just say the button name is Button1 and the Panel is Panel1
The Code i use to get the location of the Button1 is :
Dim msg = Button1.Location.X
msgbox(msg)
You're getting the screen position of the object, I don't know how because you didn't post your code. What you need to do is add the scroll offset, eg.
Position.X + scrollableControl.AutoScrollPosition.X

Form border style none was closed while minimized to tray will not restore

Created a form in VB.net 2013 with
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
And a button with
Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
The issue is, if the User closes the form while the form was minimized to the taskbar, when you start the program back up again... you can see the program in the taskbar, but clicking on the taskbar icon for the program does nothing... clicking on the notification tray icon for the program does nothing... EVEN if the notification tray icon is set to
Form.Show
Form.Activate
Form.WindowState = System.Windows.Forms.FormWindowState.Normal
I have tried forcing the form to refresh.
I have tried forcing the form to redraw itself at the initial size.
The only thing that works to show it again after this defunct state is to put
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
in the form_load event, then let the form load, stop debugging, and then comment out the line again so the form goes back to how it is suppose to be.
Am I missing something?
Also, hovering over the taskbar icon for the program shows the full form in peek... so it does appear to be loaded, just not in the state that it should be in.
Chances are that you are writing the WindowState or the location and size properties when you close the form.
If saving the location and size, make sure to first check the WindowState property:
If Me.WindowState = FormWindowState.Normal Then
'// save your form size and location
End If

VB.NET - form inside a panel resize

I can't figure this out! I've researched docking, anchoring etc. but I'm yet to get it to correctly resize when the parent form resizes.
Edit:
Quick Overview:
I have a main form with a menustrip docked to the top and a panel set to fill. I have links within the menustrip which open forms within the panel. See code below. I am struggling to get the form within the panel to resize with the panel.
I've set the panel background to black and my form inside the panel to white. I can see the panel resizing with the form correctly. The form within the panel stays in its original position. If i start my app in maximized, then click on my menustrip sure enough the form within the panel resizes correctly. However, once it is maximized it doesn't shrink with the form like the panel container does.
I've deleted everything on my whole form, added 1 panel to it and set to fill then on form load do the following:
Dim f As New Contactdetails With {.TopLevel = False, .AutoSize = True}
f.Dock = DockStyle.Fill
Me.Panel2.Controls.Add(f)
f.Show()
This still doesn't work. When i maximize my main form, the form inside the panel does not resize but the panel does as i've changed it's background to monitor its change in size
Turn AutoSize off:
Dim f As New Contactdetails With {.TopLevel = False, .AutoSize = False}
f.Dock = DockStyle.Fill
Me.Panel2.Controls.Add(f)
f.Show()
If the previous form in the panel isn't being used anymore, then you should first dispose of it:
While Me.Panel2.Controls.Count > 0
Me.Panel2.Controls(0).Dispose()
End While
Set the WindowState to Normal in properties of the child form
and
Me.Dock = DockStyle.
Fill in the Load sub of the child form

making a thumbnail toolbar (windowsAPICodePack,windows 7) button invisible in vb.net

I'm trying to make a thumbnail toolbar button (TTB from now on)visible when the it is clicked. I know how to do stuff when it is clicked, AddHandler etc. But if I tell it TTB.visible=false then it doesn't become invisible. If I put TTB.enabled = False it will be disabled, so it's only the visible that isn't working.
Also I put a button on my form (not a TTB) and when that is click wrote, TTB.visible = false and that didn't work, so there is no way to make it invisible.
Try set TTB.visible=true after you Add it into toolbar button list.